首页 > 其他 > 详细

UIAlertController 的简单使用方法

时间:2016-01-08 13:15:12      阅读:252      评论:0      收藏:0      [点我收藏+]

- (void)viewDidLoad {

    [super viewDidLoad];

    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];

    btn.frame=CGRectMake(10, 60, 80, 30);

    [btn setTitle:@"提示框" forState:UIControlStateNormal];

    btn.backgroundColor=[UIColor redColor];

    [btn addTarget:self action:@selector(gotoAlertVC) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:btn];

}

-(void)gotoAlertVC{

    UIAlertController *alertVC=[UIAlertController alertControllerWithTitle:@"提示信息" message:@"iOSQQ技术交流群436337987" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *sureAction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

        NSLog(@"确定加入");

    }];

    UIAlertAction *cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

        NSLog(@"取消加入");

    }];

    [alertVC addAction:sureAction];

    [alertVC addAction:cancelAction];

    [self presentViewController:alertVC animated:YES completion:nil];

}

 

UIAlertController 的简单使用方法

原文:http://www.cnblogs.com/shao621/p/5112753.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!