UIAlertView格式备忘

用tag区别各个AlertView

typedef NS_ENUM(NSInteger, UIAlertTag)
{
    AlertTag1,
    AlertTag2,
    AlertTag3
};

使用UIAlertViewDelegate协议

@interface UIViewController ()

@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

你可能感兴趣的:(UIAlertView格式备忘)