Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 24, 2011, 08:57 AM   #1
GhostDZ9
macrumors regular
 
Join Date: Sep 2010
TableView Checklist

Hey guys so part of my app is a checklist. The table is shown as a group rather then plain.

So basically every time they select a row it puts the accessoryCheckmark at the end of the row and removes the checkmark from everywhere else.

Is there a method or a function that basically works like

Code:
if (indexPath.row isSelected) {
    cell.AccessoryType = UITableViewAccessoryCheckmark;
} else
    cell.AccessoryType = UITableViewAccessoryNone;
__________________
- 30 GB iPod Video - Black
- 13.3" MB - 4GB RAM - 500GB 7200RPM HDD
- 16 GB iPhone 4 - Black
- Game Center Tag: GhostDZ9
GhostDZ9 is offline   0 Reply With Quote
Old May 24, 2011, 09:53 AM   #2
dejo
Demi-God (Moderator)
 
dejo's Avatar
 
Join Date: Sep 2004
Location: Colorado
I would suggest adding a Boolean flag to the data source model you use to back your table view. Then you can check against that.
__________________
My iOS Apps: a.k.a., DreamStream
I support the MacRumors Blood Drive!
dejo is offline   0 Reply With Quote
Old May 24, 2011, 09:55 AM   #3
GhostDZ9
Thread Starter
macrumors regular
 
Join Date: Sep 2010
How would I go about doing that?
__________________
- 30 GB iPod Video - Black
- 13.3" MB - 4GB RAM - 500GB 7200RPM HDD
- 16 GB iPhone 4 - Black
- Game Center Tag: GhostDZ9
GhostDZ9 is offline   0 Reply With Quote
Old May 24, 2011, 10:14 AM   #4
dejo
Demi-God (Moderator)
 
dejo's Avatar
 
Join Date: Sep 2004
Location: Colorado
Quote:
Originally Posted by GhostDZ9 View Post
How would I go about doing that?
Maybe explain how you have your data source set up.
__________________
My iOS Apps: a.k.a., DreamStream
I support the MacRumors Blood Drive!
dejo is offline   0 Reply With Quote
Old May 24, 2011, 10:58 AM   #5
GhostDZ9
Thread Starter
macrumors regular
 
Join Date: Sep 2010
Ive actually figured it out, I created an int var and then did this code

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
	}
	
	
	if (indexPath.row == selectedRow){
		cell.accessoryType = UITableViewCellAccessoryCheckmark;
	} else {
		cell.accessoryType  = UITableViewCellAccessoryNone;
	}
	cell.textLabel.text = [rows objectAtIndex:indexPath.row];
	
	return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	selectedRow = indexPath.row;
	[self.tableView reloadData];


}
__________________
- 30 GB iPod Video - Black
- 13.3" MB - 4GB RAM - 500GB 7200RPM HDD
- 16 GB iPhone 4 - Black
- Game Center Tag: GhostDZ9
GhostDZ9 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Use TableView without TableView Delegate or DataSource mikezang iPhone/iPad Programming 3 Dec 15, 2010 11:58 AM
HDTV Checklist / Recommendations ~Shard~ Buying Tips and Advice 159 Aug 5, 2007 03:23 AM
Refurb Checklist? Anything to look for? DrumaChick420 Buying Tips and Advice 2 Apr 9, 2006 10:49 PM
Switcher's Checklist for Panther Upgrade MacBytes MacBytes.com News Discussion 0 Oct 29, 2003 01:33 AM
checklist for buying from private owner Applehead Macintosh Computers 0 Jul 16, 2003 05:37 AM


All times are GMT -5. The time now is 09:48 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC