我正在尝试创建一个没有取消按钮的AlertView。
这是我尝试过的代码:
alertView.cancelButtonIndex = -1;
它似乎不适用于iOS 7。
有什么想法吗?
谢谢,
答案 0 :(得分:0)
1)使用此代码时,按“执行某些按钮”可以执行某些操作,但不会导致alertView
隐藏
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Title" message:@"The message." delegate:self cancelButtonTitle:nil otherButtonTitles: @"Do something", nil] show];
#pragma mark - UIAlertViewDelegate
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView {
return NO;
}
2)使用此代码时,alertView
上没有任何按钮(我认为这是您实际需要的)
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Title" message:@"The message." delegate:self cancelButtonTitle:nil otherButtonTitles:nil] show];