문제

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;
}
도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top