how to set the style of the TableView to "UITableViewCellStyleSubtitle". so that i can use it to display as sub title in UITABLE
A:
It's not a style of the UITableView, but of the UITableViewCell:
- (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
... more stuff
return cell;
}
David Maymudes
2009-12-07 06:30:09
is it required to add a custom cell nib to the project for sub labels? or can i add it directly in de code( ....... more stuff)
dpaksp
2009-12-07 08:49:49
you can use a nib if you want, but you don't need to. things like adding subviews that are only done with a newly created cell should actually be done inside the if (cell == nil) block, and then things like setting the text for the subviews that need to be done even for cells you're reusing should be done after that where it says "more stuff"
David Maymudes
2009-12-07 09:01:18
thanks for the info..
dpaksp
2009-12-07 09:40:25
now remember to check the little checkmark next to the answer...
David Maymudes
2009-12-07 10:11:54
this is correct. your subtitle text can be entered like the following: cell.detailTextLabel.text = @"subtitles!";
norskben
2010-02-21 21:57:17