Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-20-2010, 09:11 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 90
rk_mail04 is on a distinguished road
Default UITableview cell selection control

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
  static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
	{   
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
		[[cell imageView] setImage:[UIImage imageNamed:@"Tick.png"]];
		
    }
	
    [[cell imageView] setHidden:YES];
	
	if (indexPath.row == selectedRow) 
	{
		
		[[cell imageView] setHidden:NO];
	}
	
	NSString *cellValue =[listOfItems objectAtIndex:indexPath.row];
	cell.text = cellValue;
	return cell;


}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    	// Set up the cell...
	 selectedRow = indexPath.row;
	[self.tableView reloadData];
	
	
}
viewDidLoad
selectedRow =-1
My question about UITableView cell selection for navigation base application . After selecting my cell i am indicating in check mark for cell left side is selected. When its return to FirstviewController and back to UITableView if i check row there is no selection cell check mark. what happening now . Because i am already selected my cell. how to make selected cell is selected in appdelegate
rk_mail04 is offline   Reply With Quote
Old 12-20-2010, 09:43 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Amsterdam, The Netherlands
Posts: 782
TUX2K is on a distinguished road
Default

Wel your table is reloaded and the cell is setup for you datasource.
Since your datasource does not know that it is selected it will load the cell not selected.
You will need to save the selected state in the datasource as well.

ps your datasource = listOfItems, which just holds string.
You will have to change this to some kind of object that can hold a Boolean and a string.
TUX2K is offline   Reply With Quote
Old 12-20-2010, 10:33 AM   #3 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

basically the same question
http://www.iphonedevsdk.com/forum/ip...selection.html
__________________
dany_dev is offline   Reply With Quote
Old 12-20-2010, 11:22 AM   #4 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 90
rk_mail04 is on a distinguished road
Default

post of tutorial link or app delegate for reload. because i am totally confusing about reload and app delegate .i am not able to understand how it is internally working.

Quote:
Originally Posted by TUX2K View Post
Wel your table is reloaded and the cell is setup for you datasource.
Since your datasource does not know that it is selected it will load the cell not selected.
You will need to save the selected state in the datasource as well.

ps your datasource = listOfItems, which just holds string.
You will have to change this to some kind of object that can hold a Boolean and a string.
rk_mail04 is offline   Reply With Quote
Old 12-20-2010, 11:31 AM   #5 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Quote:
Originally Posted by rk_mail04 View Post
post of tutorial link or app delegate for reload. because i am totally confusing about reload and app delegate .i am not able to understand how it is internally working.
The essential difficulty for many in understanding tables is that the whole framework of tables has been designed around the idea of "just in time" cell construction to save memory and time. Stop thinking of a cell as a permanent object with characteristics that you can set once and forget. A cell needs to be thought of as a very temporary item that is taken apart and forgotten as soon as it scrolls off the screen and rebuilt whenever it comes back into view. That is why the datasource and delegate is so important. The datasource must be the real permanent storage for anything about the cell that needs to be re-created when the cell comes into view. And reloadData is what you do to tell the framework that the datasource has changed, and all currently-visible cells must be regenerated from the datasource so the visible cells will reflect that change.
RLScott is offline   Reply With Quote
Old 12-21-2010, 01:13 AM   #6 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 90
rk_mail04 is on a distinguished road
Default

Thanks .

Quote:
Originally Posted by RLScott View Post
The essential difficulty for many in understanding tables is that the whole framework of tables has been designed around the idea of "just in time" cell construction to save memory and time. Stop thinking of a cell as a permanent object with characteristics that you can set once and forget. A cell needs to be thought of as a very temporary item that is taken apart and forgotten as soon as it scrolls off the screen and rebuilt whenever it comes back into view. That is why the datasource and delegate is so important. The datasource must be the real permanent storage for anything about the cell that needs to be re-created when the cell comes into view. And reloadData is what you do to tell the framework that the datasource has changed, and all currently-visible cells must be regenerated from the datasource so the visible cells will reflect that change.
rk_mail04 is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 396
9 members and 387 guests
chemistry, daudrizek, HemiMG, jeroenkeij, Kirkout, PavelMik, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,665
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daudrizek
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:00 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0