Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom UITableViewCell #14

Closed
Neilfau opened this issue May 12, 2013 · 7 comments
Closed

Custom UITableViewCell #14

Neilfau opened this issue May 12, 2013 · 7 comments

Comments

@Neilfau
Copy link

Neilfau commented May 12, 2013

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
Copy link
Owner

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

@Neilfau
Copy link
Author

Neilfau commented May 13, 2013

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
Copy link
Owner

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

@Neilfau
Copy link
Author

Neilfau commented May 13, 2013

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
Copy link
Author

Neilfau commented May 13, 2013

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

@Neilfau
Copy link
Author

Neilfau commented May 13, 2013

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
Copy link
Author

Neilfau commented May 13, 2013

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.

@Neilfau Neilfau closed this as completed Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants