我正在为 ios 构建一个应用程序,我有一个导航栏按钮,将向用户显示一个带有 2 个按钮的 uialertview离开他会来到以前的视图控制器
这是.m文件的代码
-(IBAction)done:(id)sender{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello" message:@"Are You Sure??" delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if ([title isEqualToString:@"YES"]) {
segueShouldOccur = YES;
}
}
- (BOOL) shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender{
if ([identifier isEqualToString:@"perform"]) {
if (!segueShouldOccur) {
return NO;
}
}
return YES;
}
当我编译此代码时,它会执行警报视图显示,但即使我按下是或否,它也不会停留在同一页面上。请帮忙。