IOS--UIAlertView的使用方法详细

IOS--UIAlertView的使用方法详细

2015年08月31日 
  
// UIAlertView 的常用方法

   // 标准样式

   UIAlertView *oneAlertView = [[UIAlertView alloc] initWithTitle:@"标题"message:@"提示内容"delegate:self cancelButtonTitle:@"关闭"otherButtonTitles:@"OK",nil];

    [oneAlertViewshow]; // 显示出来

    [oneAlertViewrelease], oneAlertView =nil; // 释放内存


   oneAlertView.alertViewStyle = UIAlertViewStyleDefault; //设置oneAlerView的样式

//   UIAlertViewStyleDefault 只弹信息和按钮

//   UIAlertViewStyleSecureTextInput 有一个textfield加密框

//   UIAlertViewStylePlainTextInput 有一个不加密的textfield

//   UIAlertViewStyleLoginAndPasswordInput 有两个textfieldLoginpassword

IOS--UIAlertView的使用方法详细




//按钮横排显示

   UIAlertView *twoAlertView = [[UIAlertView alloc] initWithTitle:@"标题"message:@"提示内容"delegate:self cancelButtonTitle:@"关闭"otherButtonTitles:@"按钮1",@"按钮2",@"按钮2",nil];

    [twoAlertViewshow]; // 显示出来

    [twoAlertViewrelease], twoAlertView =nil; // 释放内存

IOS--UIAlertView的使用方法详细

//添加了多个按钮,那么要怎么判断我们按下的是哪个按钮呢?

//需要在.h文件中实现UIAlertViewDelegate代理,然后在.m文件中重写下面的方法

 

#pragma mark - 实现UIAlertView的代理方法判断按了哪个按钮

-(void)alertView:(UIAlertView *)alertViewclickeonAtIndex:(NSInteger)buttonIndex {

   //获取您按下的是哪个按钮

    NSString* msg = [[NSString alloc] initWithFormat:@"您按下的第%d个按钮!",buttonIndex];

    NSLog(@"%@", msg);

    [msgrelease], msg = nil;

   // 点击取消按钮1”按钮2”按钮3”的索引buttonIndex分别是0123

}




 

   //UIAlertView添加其他

   UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@"请等待"

                                      message:nil

                                     delegate:nil

                               cancelButtonTitle:nil

                               otherButtonTitles:nil];

    [alertshow];

   UIActivityIndicatorView *activeView = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

   activeView.center =CGPointMake(alert.bounds.size.width/2.0f, alert.bounds.size.height-40.0f);

    [activeViewstartAnimating];

    [alertaddSubview:activeView];

    [activeViewrelease];

    [alertrelease];

IOS--UIAlertView的使用方法详细
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值