I've spent way to long on the trying to figure out why this button won't call its selector. Does anyone see anything obvious that I'm doing wrong? I add the button to my view
Code:
- (id)initWithFrame:(CGRect)frame {
if((self = [super initWithFrame:frame])) {
[self addSubview:self.backButton];
}
return self;
}
- (void)awakeFromNib {
[self addSubview:self.backButton];
}
- (UIButton *)backButton {
if(backButton_ == nil && self.presentingViewController != nil) {
backButton_ = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
[backButton_ setTitle:@"Back" forState:UIControlStateNormal];
[backButton_ addTarget:self action:@selector(backButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[backButton_ setUserInteractionEnabled:YES];
backButton_.frame = CGRectMake(self.bounds.size.width-20-50, 20, 50, 44);
}
return backButton_;
}
- (void)backButtonPressed:(id)sender {
NSLog(@"pressed");
[self.presentingViewController dismissModalViewControllerAnimated:YES];
}