开发者

UITableView detailTextLabel - iphone development

why is "detailTextLabel" not working anymore?

- (UITa开发者_JS百科bleViewCell *)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];
    }

    // Configure the cell.
    cell.textLabel.text=[listData objectAtIndex:[indexPath row]];
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;


    cell.detailTextLabel.text=@"hi";
    return cell;
}


Try to change the style of the cell, use this code while initializing the cell

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

For more information about the cell styles look at the apple's class reference


You've chosen a cell style UITableViewCellStyleDefault that does not support a detailTextLabel

Try using a different style.

edit

You choose a style in the initWithStyle:reuseIdentifier; method. Have a look at the UITableViewCell docs which describes the available cell styles.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜