I\'m trying to add a custom delegate to a custom UITableViewCell of mine.
On this cell I have a button which need to fire a method in the ViewController where the UI
I have heard that synthesized accessors should not be used during init
. Try to do all the setup code using the ivars directly:
myButton = [[UIButton alloc] init];
myButton.backgroundColor = [UIColor clearColor];
myButton.frame = CGRectMake(5, 0, 10, 32); myButton.titleLabel.adjustsFontSizeToFitWidth = YES;
[myButton addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
[contentView addSubview:myButton];
If you change your button creation to [UIButton buttonWithType:UIButtonTypeCustom];
as beryllium rightly suggests, then you will also need to retain
it.