我有一个标题为有趣的故事从故事板中设置的按钮
在viewDidLoad中,我更改了标题
self.catBut.titleLabel.text = @"Random";
然后点击另一个按钮
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title alert" message:@"Alert message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
但是在提醒出现后,按钮的标题会改回 Fun
答案 0 :(得分:0)
.h文件保留此
@property(non atomic,strong)IBOutlet UIButton *catBut;
使用它来更改按钮标题
[self.catBut setTitle:@"Random" forState:UIControlStateNormal];
使用UIAlertViewDelegate
方法
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title alert" message:@"Alert message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
alert.tag==100; //if u used multiple alert in your VC, use to identify the Tag
[alert show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag==100)
{
[self.catBut setTitle:@"Random" forState:UIControlStateNormal];
}
else
{
// anotehr mthod optiobns
}
}