我的代码中有一个方法:
-(IBAction) actionButtonPressed: (id) sender{
NSLog(@"%@",actionButton.titleLabel.text);
if (actionButton.titleLabel.text == @"Begin Recording"){
[actionButton setTitle:@"Finish Recording" forState:UIControlStateNormal];
[actionButton setTitle:@"Finish Recording" forState:UIControlStateApplication];
[actionButton setTitle:@"Finish Recording" forState:UIControlStateHighlighted];
[actionButton setTitle:@"Finish Recording" forState:UIControlStateReserved];
[actionButton setTitle:@"Finish Recording" forState:UIControlStateSelected];
[actionButton setTitle:@"Finish Recording" forState:UIControlStateDisabled];
UIImage *redButton = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bigredbutton" ofType:@"png"]];
[actionButton setBackgroundImage:redButton forState:UIControlStateNormal];
[actionButton setBackgroundImage:redButton forState:UIControlStateApplication];
[actionButton setBackgroundImage:redButton forState:UIControlStateHighlighted];
[actionButton setBackgroundImage:redButton forState:UIControlStateReserved];
[actionButton setBackgroundImage:redButton forState:UIControlStateSelected];
[actionButton setBackgroundImage:redButton forState:UIControlStateDisabled];
}
if (actionButton.titleLabel.text == @"Finish Recording"){
[self dismissModalViewControllerAnimated:YES];
}
}
出于某种原因,NSLog 调用确实有效并显示在控制台上。该按钮开始读取 Begin Recording,但即使它与 Interface Builder 中的 Touch Up Inside 绑定以调用此方法并被引用,按下它也无济于事。