我在Xcode 5的iOS应用程序中显示UIAlertView
。它是一个标签式应用程序。 UIAlertView
显示在默认选项卡(第一个选项卡)上,当解除警报视图时,应用程序会自动跳到第三个选项卡。
代码是:
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
if (granted) {
// Microphone enabled code
}
else {
// Microphone disabled code
recordButton.userInteractionEnabled = NO;
microPhoneAlert = [[UIAlertView alloc]initWithTitle:@"Microphone is Turned Off" message:@"Message" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[microPhoneAlert show];
}
}];
并以viwDidLoad编写。
,委托方法是:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView == microPhoneAlert)
{
}
}
有人能说出为什么会这样吗?
谢谢。 。 。 :)答案 0 :(得分:0)
我解决了。 。 。当我将委托设置为nil时,这很好:
recordButton.userInteractionEnabled = NO;
microPhoneAlert = [[UIAlertView alloc]initWithTitle:@"Microphone is Turned Off" message:@"Message" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[microPhoneAlert show];