FPPopover cell.detailTextLabel.text

时间:2013-08-24 01:28:54

标签: iphone uitableview fppopover

对于熟悉FPPopOver的人:https://github.com/50pixels/FPPopover

单元格可以显示字幕吗?我不得不将UITableViewController贴在笔尖上。

在故事板中我将单元格设置为显示字幕,但是,当iPhone上显示popOver时,只有cell.textLabel.text可见 - cell.detailTextLabel.text未显示。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    if (cell==nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
    NSString  *entityName= [[managedObject entity]name];
    cell.textLabel.text = [NSString stringWithFormat:@"%@   %i", entityName, [indexPath row]];       
    cell.detailTextLabel.text = @"Subtitle";

}

这是图片: enter image description here

更新 使用标签显示字幕后,在将单元格滚动回视图后,会发生以下情况:

enter image description here

1 个答案:

答案 0 :(得分:2)

如果它根本不工作,那么替代方法就是你可以使用lable并设置lable框架作为详细文本,并添加lable作为cell.contentview addsubview,这样你就可以在tableview单元格上获得你的详细文本

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = (UITableViewCell*)[tblUser dequeueReusableCellWithIdentifier:nil];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];        
}
NSMutableDictionary *objUser = [arrUser objectAtIndex:indexPath.row];

    strName = [objUser objectForKey:@"Name"];
    strDate = [objUser objectForKey:@"Date"];

    UILabel *lblName = [[UILabel alloc] initWithFrame:CGRectMake(85, 10, 215, 20)];
    lblName.text = strName;
    lblName.textColor = [UIColor whiteColor];
    [lblName setBackgroundColor:[UIColor clearColor]];
    [cell.contentView addSubview:lblName];

    UILabel *lblDate = [[UILabel alloc] initWithFrame:CGRectMake(85, 34, 215, 20)];
    lblDate.text = strDate;
    lblDate.textColor = [UIColor whiteColor];
    [lblDate setBackgroundColor:[UIColor clearColor]];
    [cell.contentView addSubview:lblDate];
return cell;
}
相关问题