Question

I'm trying to do some CALayer stuff on a UIButton that resides inside a uitableviewcell. I've imported but the CALayer manipulation is not working. When I moved it to cellForRowAtIndexPath method it works fine. I do want to make the change once inside the class of the cell itself and not inside the table creation table. Do you have any ideas ?

By the way, I do see the NSLog text on the init (so I know it entered the block).

Thanks !

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        NSLog(@"STARTED coder init in testResultCell");
        [[self.bubbleMore layer] setMasksToBounds:YES];
        [[self.bubbleMore layer] setBorderWidth:3.0f];
        [[self.bubbleMore layer] setBorderColor:[UIColor blueColor].CGColor];
        [[self.bubbleMore layer] setCornerRadius:20.0f];
    }
    return self;
}
Was it helpful?

Solution

Move the code to awakeWithNib. Your outlets won't be connected yet in initWithCoder. From Apple's documentation:

When an object receives an awakeFromNib message, it is guaranteed to have all its outlet instance variables set.

OTHER TIPS

User interface objects are not available until viewDidLoad is called, which actually loads controls from your xib or Storyboard. Please move your code to viewDidLoad and it should work just fine.

If you add a breakpoint and look at the self.bubbleMore, it is going to be nil in initWithCode function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top