1

For those that are familiar with FPPopOver: https://github.com/50pixels/FPPopover

Can the cells display subtitle? I had to attach my UITableViewController to a nib.

In the Storyboard I have the cell set up to show subtitle, however, when the popOver appears on the iPhone, only cell.textLabel.text is visible - cell.detailTextLabel.text is not appearing.

- (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";

}

Here is the image: enter image description here

Update After using Labels to display the subtitle, after scrolling the cell back into the view, the following happens:

enter image description here

JOM
  • 8,139
  • 6
  • 78
  • 111
user1107173
  • 10,334
  • 16
  • 72
  • 117

1 Answers1

2

if it's not working at all then alternative of that is you can use lable and set frame of lable as detail text has and add that lable as cell.contentview addsubview so this way you'll get your detail text on your tableview cell.

- (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;
}
D-eptdeveloper
  • 2,430
  • 1
  • 16
  • 30
  • 1
    take a look i've edited my answer, so this is how you can add lable to cell and make changes as per your requirement like detail text fonts and area and main title text fonts and area all those according to your requirement. – D-eptdeveloper Aug 26 '13 at 04:10
  • Thank you! I left cell.textLabel.text as it is, and used labels only for the cell.detailLabel.text. It's working, however, when the cells reappear, it seems like the new labels are placed on top of the old ones. I have updated the question. – user1107173 Aug 28 '13 at 03:39
  • @user1107173 : i think now my edited answer will help you.i've again edited it so please take a look thanks. – D-eptdeveloper Aug 31 '13 at 05:27