首页 > 其他 > 详细

UI第十二节

时间:2017-01-03 11:41:10      阅读:154      评论:0      收藏:0      [点我收藏+]

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    btn.frame = CGRectMake(40, 100, 295, 30);
    [btn setTitle:@"Show Alert View" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}

- (void)btnClicked:(UIButton *)btn
{
    // 实例化 UIAlertView
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"这是Title" message:@"这里是提示的信息" delegate:self cancelButtonTitle:@"取消按钮" otherButtonTitles:@"确认", nil];
    
    // 显示UIAlertView
    [alertView show];
}

// 用户点击UIAlertView上的按钮时会调用这个代理方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    // 通过ButtonIndex来判断用户点击的是哪一个Button
    NSLog(@"%ld, %@", buttonIndex, [alertView buttonTitleAtIndex:buttonIndex]);
}

UI第十二节

原文:http://www.cnblogs.com/laolitou-ping/p/6244179.html

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