首页 > 移动平台 > 详细

IOS 开发 弹框 UIAlertView 与UIAlertController

时间:2016-01-02 00:58:06      阅读:261      评论:0      收藏:0      [点我收藏+]
//View 里面的一个按钮
- (IBAction)showAlert:(id)sender {
    //ios8 之前
    UIAlertView * alert=[[UIAlertView alloc]
                         initWithTitle:@"你好,波多老师"
                         message:@"听说您??有新戏要上映了"
                         delegate:nil
                         cancelButtonTitle:@"我来贡献票房来了"
                         otherButtonTitles:nil, nil
                         ];
    
    [alert show];
    
    //IOS 8 之后
    UIAlertController * newAlert=[UIAlertController
                                  alertControllerWithTitle: @"你好,苍老师"
                                  message:@"听说您也??有新戏要上映了"
                                  preferredStyle:UIAlertControllerStyleAlert
                                  ];
    
    UIAlertAction * newAlertAction=[UIAlertAction
                                    actionWithTitle:@"我来贡献票房来了"
                                    style:UIAlertActionStyleDefault
                                    handler:nil
                                    ];
    //弹框按钮
    [newAlert addAction:newAlertAction];
    
    //初始化弹框
    [self presentViewController:newAlert animated:true completion:nil];
}

 

IOS 开发 弹框 UIAlertView 与UIAlertController

原文:http://www.cnblogs.com/acgk/p/5093941.html

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