用tag区别各个AlertView
typedef NS_ENUM(NSInteger, UIAlertTag)
{
AlertTag1,
AlertTag2,
AlertTag3
};
使用UIAlertViewDelegate协议
@interface UIViewController ()<UIAlertViewDelegate>
@end
使用AlertView
@implementation UIViewController
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:title
message:message
delegate:self
cancelButtonTitle:leftString
otherButtonTitles:rightString, nil];
alertView.tag = tag;
[alertView show];
实现代理
#pragma mark - UIAlertView delegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0){
}
}
@end