alertview 使用

typedef enum{

alertviewType1,

alertviewType2,

} alertviewType;

 

@interface ZBMainViewController ()<UIAlertViewDelegate>

 

@end

 

@implementation ZBMainViewController

 

 

 

 

- (void)viewDidLoad

{

    [super viewDidLoad];

    

    //导航栏是否透明  no是透明

    

    [self.navigationController.navigationBar setTranslucent:NO];

 

     self.navigationItem.title = @"张先森";   //    self.title=@"张先森";

    

    [self.navigationController.navigationBar setBarTintColor:[UIColor purpleColor]];

 

 

    [self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"测试" style:UIBarButtonItemStyleDone target:self action:@selector(leftClick:)]];

}

 

-(void)leftClick:(UIBarButtonItem *)item{

    UIAlertView *view=[[UIAlertView alloc] initWithTitle:@"测试" message:@"你大爷" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"yes", nil];

     view.tag=alertviewType1;

    [view show];

}

 

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

 

    if (alertView.tag==alertviewType1) {

        

        if (buttonIndex==0) {

            

        }

        

        

        

    }

 

 

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 6   UIAlertView *altView = [[UIAlertView alloc]initWithTitle:[self altTitle] message:[self altMSG] delegate:self cancelButtonTitle:[self cancelBtnTitle] otherButtonTitles:[self otherBtnTitle], nil];
7     // 2、显示 alertView
8     [altView show];

 

 

 

 22 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
23 {
24     NSString *btnTitle = [alertView buttonTitleAtIndex:buttonIndex];
25     if ([btnTitle isEqualToString:[self cancelBtnTitle]]) {
26         NSLog(@"你点击了退出");
27     }
28     else if ([btnTitle isEqualToString:[self otherBtnTitle]] ) {
29         NSLog(@"你点击了重新登录按钮");
30     }
31 }

posted @ 2014-11-22 00:54  銱ル╬鎯噹  阅读(139)  评论(0编辑  收藏  举报