honcheng / PaperFoldMenuController

A navigation menu on the left of the screen using on PaperFold
Other
436 stars 90 forks source link

Custom UITableViewCell #14

Closed Neilfau closed 2 years ago

Neilfau commented 11 years ago

Hi, im trying to use a custom UITableViewCell, when i try to set a UILabel text nothing appears, the label is blank but if i use the NSLog the label.text is showing the correct title, so i know the label is getting assigned the text value. Any ideas what I'm doing wrong?

heres the code for the MenuView:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 NSString *CellIdentifier = @"Cell";
 MenuCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
 if (cell == nil) {
     cell = [[MenuCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
 }

NSMutableDictionary *menuItem = [menuArray objectAtIndex:indexPath.row];
NSString *title = [menuItem objectForKey: @"Title"];

if (indexPath.row % 2) {

    cell.contentView.backgroundColor = [UIColor whiteColor];

}

else{

    cell.contentView.backgroundColor = [UIColor darkGrayColor];
    cell.menuTitleLabel.textColor = [UIColor whiteColor];
}

cell.menuTitleLabel.text = title;
NSLog(@"MenuTitleLabel = %@", cell.menuTitleLabel.text);

return cell;
}
honcheng commented 11 years ago

Hi Neilfau, Can't spot anything wrong here..

Neilfau commented 11 years ago

Hi, thanks for your quick response. Yes its strange, if i use:

[cell textlabel setText:title];

Everything works fine, but soon as i use my custom uilabel the cell is blank, but cell.menuTitleLabel.text has the correct value assigned to it.

honcheng commented 11 years ago

Hi Neilfau, Can you check if your label is behind textLabel? Maybe make textLabel background clear to help with debugging

Neilfau commented 11 years ago

Hi, thanks for your quick response. Yes its strange, if i use:

[cell textlabel setText:title];

Everything works fine, but soon as i use my custom uilabel the cell is blank, but cell.menuTitleLabel.text has the correct value assigned to it.

Neilfau commented 11 years ago

Ok ill give that a try later & let you know. Thanks.

Neilfau commented 11 years ago

Ok, I tried making the textLabel background clear, still no difference. I tried setting menuTitleLabel background colour too black too see if it would show up, but the cell remains blank. Im completely confused to why it's behaving in this way.

Neilfau commented 11 years ago

When i log the cell i get this:

Cell: <MenuCell: 0x9e857c0; baseClass = UITableViewCell; frame = (0 0; 200 90); hidden = YES; autoresize =    W; layer = <CALayer: 0x9e85970>>

For some reason the cell is HIDDEN, I've tried setting the cell.hidden to NO when the cell is initialised, but its still be set as hidden somewhere.