zoukankan      html  css  js  c++  java
  • UIAlertView和UIAlertViewController

     1 #import "ViewController.h"
     2 
     3 @interface ViewController ()<UIAlertViewDelegate>
     4 
     5 @end
     6 
     7 @implementation ViewController
     8 
     9 - (void)viewDidLoad {
    10     [super viewDidLoad];
    11     // Do any additional setup after loading the view, typically from a nib.
    12 }
    13 - (IBAction)didClickButtonAction:(UIButton *)sender {
    14     
    15     //版本判断
    16     float version = [UIDevice currentDevice].systemVersion.floatValue;
    17     if (version < 8.0) {
    18         
    19         //iOS8.0以前UIAlertView,用show展示
    20             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"密码错误" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",@"孟德峰",@"原溢凯", nil];
    21             //弹出alertView
    22             [alertView show];
    23         
    24     }else{
    25         //iOS8.0以后UIAlertController,用模态展示
    26         UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"提示" message:@"密码错误" preferredStyle:UIAlertControllerStyleActionSheet];
    27         //添加点击按钮
    28         [alertC addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    29             NSLog(@"点击确定");
    30         }]];
    31         [self presentViewController:alertC animated:YES completion:nil];
    32     }
    33     
    34 }
    35 //代理方法,判断点击了那个按钮
    36 -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    37 {
    38     NSLog(@"%ld",buttonIndex);
    39 }
  • 相关阅读:
    Robot Framework + Selenium library + IEDriver环境搭建
    【转】大话测试数据(一)
    TEST DESIGN TECHNIQUES: AN OVERVIEW
    24 WHEN CAN WE STOP TESTING?
    MySql Trace
    ORGANISING THE TEST CASES
    angular教程
    vue报错一
    sort()
    时间戳
  • 原文地址:https://www.cnblogs.com/DevinSMR/p/5285050.html
Copyright © 2011-2022 走看看