zoukankan      html  css  js  c++  java
  • 警告对话框&等待提示器

     1 @synthesize alertView = _alertView;
     2 @synthesize activityIndicator = _activityIndicator;
     3 
     4 - (void)viewDidLoad {
     5     [super viewDidLoad];
     6 
     7     for(int i=0;i<2;i++){
     8         UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     9         
    10         btn.frame = CGRectMake(100, 100+i*100, 100, 40);
    11         
    12         if(i==0)
    13         {
    14             [btn setTitle:(@"警告提示框") forState:UIControlStateNormal];
    15         }
    16         else if(i==1)
    17         {
    18             [btn setTitle:(@"等待指示器") forState:UIControlStateNormal];
    19         }
    20         btn.tag = 101 + i;
    21         
    22         [btn addTarget:self action:@selector(pressBtn:) forControlEvents:UIControlEventTouchUpInside];
    23         
    24         [self.view addSubview:btn];
    25     }
    26 
    27 }
    28 
    29 -(void) pressBtn:(UIButton *) btn
    30 {
    31     if(btn.tag == 101)
    32     {
    33         _alertView = [[UIAlertView alloc] initWithTitle:@"警告" message:@"您的电量过低" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"朕知道了",@"11",@"22", nil];
    34         [_alertView show];
    35     }else if(btn.tag == 102)
    36     {
    37         //宽度高度不可变
    38         _activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(100, 500,80,80)];
    39         
    40         _activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
    41         
    42         self.view.backgroundColor = [UIColor blackColor];
    43         
    44         [self.view addSubview:_activityIndicator];
    45         
    46         [_activityIndicator startAnimating];
    47     }
    48    
    49     
    50 }
    51 //当点击对话框的按钮时,调用此函数
    52 -(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    53 {
    54     NSLog(@"index = %ld
    ",buttonIndex);
    55     
    56 }
    57 
    58 //对话框即将消息,此函数被调用
    59 
    60 -(void) alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
    61 {
    62     NSLog(@"will dismiss");
    63     
    64 }
    65 
    66 
    67 -(void) alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
    68 {
    69     NSLog(@"have already dismissed");
    70     
    71 }
    72 
    73 - (void)didReceiveMemoryWarning {
    74     [super didReceiveMemoryWarning];
    75     // Dispose of any resources that can be recreated.
    76 }
    77 
    78 
    79 @end
     1 @interface ViewController : UIViewController<UIAlertViewDelegate>
     2 {
     3     //定义一个警告提示框
     4     UIAlertView* _alertView;
     5     //定义一个等待提示对象,转圈
     6     UIActivityIndicatorView* _activityIndicator;
     7     
     8 }
     9 
    10 //属性定义
    11 @property(retain,nonatomic) UIAlertView* alertView;
    12 
    13 @property(retain,nonatomic) UIActivityIndicatorView* activityIndicator;
  • 相关阅读:
    实体类中的date类型问题
    java.sql.SQLException: validateConnection false
    本地计算机的mysql服务启动后停止
    VUE遇到Windows 64-bit with Unsupported runtime (64) For more information on which environments are supported please see
    有关详细信息, 请使用 -Xlint:unchecked 重新编译。
    mysql出错ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
    WIN7系统如何在文件列表中显示文件夹后缀
    shell 两类执行方法
    Git 报错 error setting certificate verify locations
    maven打包不同jdk版本的包
  • 原文地址:https://www.cnblogs.com/vector11248/p/7593283.html
Copyright © 2011-2022 走看看