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 *)alertView clickedButtonAtIndex:(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 = [[UIActivityIndicatorViewalloc]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自己慢慢试试。这些基本够用了。。。

IOS--UIAlertView的使用方法详细的更多相关文章

  1. iOS App上架流程(2016详细版)

    iOS App上架流程(2016详细版) 原文地址:http://www.jianshu.com/p/b1b77d804254 感谢大神整理的这么详细 一.前言: 作为一名iOSer,把开发出来的Ap ...

  2. iOS - UIAlertView

    前言 NS_CLASS_DEPRECATED_IOS(2_0, 9_0, "UIAlertView is deprecated. Use UIAlertController with a p ...

  3. iOS与HTML5交互方法总结(转)

    今天小编在找技术文章的时候,发现这样一个标题:iOS与HTML5交互方法总结,怎么看着这么熟悉呢?   还以为是刚哥用了别的文章,点进去一看,原来是刚哥自己写的文章,他们转载的,而且还上了Dev St ...

  4. IOS--UILabel的使用方法详细

    IOS-UILabel的使用方法详细   //UILabel的使用 UILabel *oneLabel = [[UILabel alloc] init]; // 最经常使用的 oneLabel.fra ...

  5. IOS--UIDatePicker 时间选择器 的使用方法详细

    IOS--UIDatePicker 时间选择器 的使用方法详细 // 主要有下面四种类型:   // 日期显示. // 日期和时间显示. // 时间显示. // 倒计时选择       // UIDa ...

  6. UIAlertView的使用方法

    UIAlertView的使用方法 1. 最简单的用法 UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@"提示" mes ...

  7. [iOS]数据库第三方框架FMDB详细讲解

    [iOS]数据库第三方框架FMDB详细讲解 初识FMDB iOS中原生的SQLite API在进行数据存储的时候,需要使用C语言中的函数,操作比较麻烦.于是,就出现了一系列将SQLite API进行封 ...

  8. 模式识别 - libsvm该函数的调用方法 详细说明

    libsvm该函数的调用方法 详细说明 本文地址: http://blog.csdn.net/caroline_wendy/article/details/26261173 须要载入(load)SVM ...

  9. iOS数据库操作之coredata详细操作步骤

    CHENYILONG Blog iOS数据库操作之coredata详细操作步骤 技术博客http://www.cnblogs.com/ChenYilong/ 新浪微博http://weibo.com/ ...

随机推荐

  1. VMware: windows8 与 虚拟机ubuntu 14.04 共享文件夹

    假设当前用户为xxx 安装 VMwareTools 1. 打开 VMwareworkstation窗口,选择”虚拟机” -> “重新安装VMwareTools(T)”. 点击之后,会发现 Ubu ...

  2. 根据新浪天气API获取各地天气状况(Java实现)

    原文出自 参考网址(重要) http://blog.csdn.net/cyxlzzs/article/details/7602469  新浪 http://blog.csdn.net/l_ch_g/a ...

  3. Unity3D NGUI制作进度条

    利用GUI可以制作进度条,但是NGUI更加方便 我是用的NGUI3.5.3, 先找到NGUI  Slider的预制体,利用自带的UISlider来制作. 主要是利用UISlider的Value来控制进 ...

  4. gradle 集成到myeclipse

    新的项目用到gradle,所以学了下,地址:http://dist.springsource.com/release/TOOLS/gradle :help 下,安装好,重启即可,gradle作为mav ...

  5. Linux下tomcat使用

    http://tomcat.apache.org/download-70.cgi这里下载 放到Linux目录下,解压开, 默认port:8080能够直接使用 经常使用启动命令catalina.sh   ...

  6. View获取焦点

    <EditText android:id="@+id/et_phoneNum" android:layout_width="match_parent" a ...

  7. Android CountDownTimer 倒计时

    摘自:http://www.cnblogs.com/over140/archive/2011/12/20/2294220.html 继承关系 public abstract class CountDo ...

  8. Codeforces 437B The Child and Set

    题目链接:Codeforces 437B The Child and Set 開始是想到了这样的情况,比方lowbit之后从大到小排序后有这么几个数,200.100,60.50.S = 210.那先选 ...

  9. C#中的IO流操作(FileStream)

    StreamReader和StreamWriter适用于对文本文件的操作,因为它是以字符为单位进行的操作 不用担心编码问题 using (Stream s = new FileStream(@&quo ...

  10. PHP微信公众号 access_token缓存

    PHP创建access_token.json文件,将access_token 和 生成时间expires 保存在其中, {"access_token":"xxxx&quo ...