美文网首页
UIAlertView 点击跳转

UIAlertView 点击跳转

作者: 对歌当酒 | 来源:发表于2015-11-10 21:36 被阅读684次

iOS 开发中,经常遇到弹出框。之前没在意过弹出框的点击方法,直到这几天用到的时候。因此也做了个小结,代码如下:

// 弹出框
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                message:@"退出吗?"
                                               delegate:self
                                      cancelButtonTitle:@"确认"
                                      otherButtonTitles:nil];
alert.tag = 1; //注意这个操作
[alert show];

// 根据 AlertView 的 tag 判断是哪个弹出框,并作出响应
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (alertView.tag == 1) { 
       [self.navigationController popViewControllerAnimated:YES]; 
    }
}

相关文章

网友评论

      本文标题:UIAlertView 点击跳转

      本文链接:https://www.haomeiwen.com/subject/rqmchttx.html