I am using IOX8 and Xcode 6. I created a table with a customtype cell in storyboard, and I placed a label in it. I entered a tag number for the label in the IB, so that I could retrieve a reference to the label in my code. But when I try to get a reference to the label inside my "cellForRowAtIndexPath", using viewWithTag I get a NIL for the label :
This are the two lines of code that are important in cellForRowAtIndexPath:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PlayerCell"];
UILabel *nameLabel = (UILabel *)[cell viewWithTag:1];
The "cell viewWithTag:1" line returns NIL, I don't understand why.
I also tried "cell.contentView withWithTag:1" and that did not work either.
Is this a bug in IOS 8 or Xcode 6?
thanks
-Malena
Uncheck Size Classes option in the storyboard and clean & build the app. It should work now.
I met the same problem when I was using IOS8 and Xcode 6.1. I found that if I enable the Size Classes
, viewWithTag
always return nil
. I think it may be a bug for Xcode 6.x. Just disable the Size Classes
, everything goes ok.
Try to make the view 'installed
', check this link:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With