• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[iphone] UITableViewCell set cell attributes based on indexPath.row number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iphone] UITableViewCell set cell attributes based on indexPath.row number


  • Subject: [iphone] UITableViewCell set cell attributes based on indexPath.row number
  • From: Philip Vallone <email@hidden>
  • Date: Mon, 23 Nov 2009 20:02:16 -0500

Hi List,

If I have an UITableViewCell and want to set the cell attributes based on indexPath.row number, how could I do this? In the below example, the cells are drawn dynamically and work until the user moves the table. When the first 4 four rows are redrawn, their font changes. How do I set the first four rows to a color and not have it change?


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


	NSLog(@"Painting Row Number %d",	indexPath.row);

	static NSString *CellIdentifier = @"Cell";
    	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    	if (cell == nil) {

		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

    	}

	[cell.textLabel setText:[tableList objectAtIndex:indexPath.row]];
	[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];

	cell.textLabel.font = [UIFont systemFontOfSize:14];
	cell.textLabel.numberOfLines = 2;

	if (indexPath.row > 3) {

		cell.textLabel.textColor = [UIColor redColor];

	}


return cell;
}

Thanks,

Phil_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: [iphone] UITableViewCell set cell attributes based on indexPath.row number
      • From: Brian Slick <email@hidden>
  • Prev by Date: Problem on NSPopUpButton Class
  • Next by Date: Re: UI Question: Hide application window after minimising
  • Previous by thread: Re: Problem on NSPopUpButton Class
  • Next by thread: Re: [iphone] UITableViewCell set cell attributes based on indexPath.row number
  • Index(es):
    • Date
    • Thread