tags:

views:

219

answers:

1

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
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
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
thanks for the info..
dpaksp
now remember to check the little checkmark next to the answer...
David Maymudes
this is correct. your subtitle text can be entered like the following: cell.detailTextLabel.text = @"subtitles!";
norskben