打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
IOS UIAlertView
//UIAlertView的常用方法

  // 标准样式

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

  [oneAlertView show]; // 显示出来

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

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

  // UIAlertViewStyleDefault只弹信息和按钮

  // UIAlertViewStyleSecureTextInput 有一个textfield加密框

  // UIAlertViewStylePlainTextInput 有一个不加密的textfield

  // UIAlertViewStyleLoginAndPasswordInput 有两个textfield,Login和password

  


  //按钮横排显示

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

  [twoAlertView show]; // 显示出来

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

  


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

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

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

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

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

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

  NSLog(@"%@", msg);

  [msg release], msg = nil;

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

  }

  // 给UIAlertView添加其他

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

  message:nil

  delegate:nil

  cancelButtonTitle:nil

  otherButtonTitles:nil];

  [alert show];

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

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

  [activeView startAnimating];

  [alert addSubview:activeView];

  [activeView release];

  [alert release];

  


  //还有很多方法,想深入了解的可以查看api自己慢慢试试。这些基本够用了。。。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
iPhone入门 - UIAlertView用法
实例编程iPhone 录音和播放
iPad与iPhone调用UIImagePickerViewController方法
自己整理的ios app实现自动升级
UIAlertView使用全解
Ipad开发课程-Charpter3 窗口工具 ? 疯狂的老九
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服