iOS中UIAlertView的使用方法

UIAlertView * alertView=[[UIAlertView
alloc]initWithTitle:nil

message:@"真的要退出?"

delegate:self

cancelButtonTitle:@"确定"

otherButtonTitles:@"取消",
nil];

alertView.tag=11;

[alertView show];

然后实现

UIAlertViewDelegate的代理方法

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

//执行的代码

}

2.3带输入框的Alert

//登陆弹出框:一个文本输入框,一个密码框

UIAlertView *alertView = [[UIAlertView alloc]

initWithTitle:@"Password" message:@"Please enter your credentials" delegate:self

cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];

//设置AlertView的样式

[alertView setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];

[alertView show];

//登陆弹出框:一个文本输入框,一个密码框

UIAlertView *alertView = [[UIAlertView alloc]

initWithTitle:@"Password" message:@"Please enter your credentials" delegate:self

cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];

//设置AlertView的样式

[alertView setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];

[alertView show];

 UIAlertViewStylePlainTextInput 添加一个普通输入框 
 UIAlertViewStyleSecureTextInput  密码输入框
 UIAlertViewStyleLoginAndPasswordInput  普通输入框加密码输入框
-(void)alertView
: (UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
2
3        //得到输入框
4        UITextField
*tf=[alertView textFieldAtIndex:0];
5 }

时间: 2024-07-31 01:10:51

iOS中UIAlertView的使用方法的相关文章

iOS中数组遍历的方法及比较

数组遍历是编码中很常见的一种需求,我们来扒一拔iOS里面都有什么样的方法来实现,有什么特点. 因为iOS是兼容C语言的,所以C语言里面的最最常见的for循环遍历是没有问题的. 本文中用的数组是获取的系统的语言数组,大约有30多个数据,虽然还不够模拟大批量的数据,但对于方法的验证是没有问题的了. NSArray *langArray = [[NSUserDefaults standardUserDefaults] arrayForKey:@"AppleLanguages"]; 第一种方法

ios中图像进行压缩方法汇总

ios中图像进行压缩方法汇总 在Iphone上有两种读取图片数据的简单方法: UIImageJPEGRepresentation和UIImagePNGRepresentation. UIImageJPEGRepresentation函数需要两个参数:图片的引用和压缩系数.而UIImagePNGRepresentation只需 要图片引用作为参数. 方法一: 代码如下: - (UIImage*)scaleFromImage:(UIImage*)image scaledToSize:(CGSize)

IOS中block的使用方法

X.1 初探Block 在这一小节我们先用一些简单范例来导入block的概念. X.1.1 宣告和使用Block 我们使用「^」运算子来宣告一个block变数,而且在block的定义最后面要加上「;」来表示一个完整的述句(也就是将整个block定义视为前面章节所介绍的简单述句,因为整个定义必须是一个完整的句子,所以必须在最后面加上分号),下面是一个block的范例: 1: int multiplier = 7 ; 2: int (^myBlock)( int ) = ^( int num) 3:

iOS中解析json多种方法

我感觉JSON解析,重要的是JSON解析之后对结果的处理JSON解析后是个dictionary,但是字典中有可能包含字典和数组,数组中还可以包含字典.向客户端请求的返回数据解析下面就简单介绍一下JSON解析过程其实就一句话 "data就是解析数据"!!!!!!!!!!!!!! //xcode自带解析类NSJSONSerialization从data中解析出数据放到字典中NSDictionary *weatherDic = [NSJSONSerialization JSONObjectW

iOS中数组遍历的方法及比較

数组遍历是编码中非经常见的一种需求.我们来扒一拔iOS里面都有什么样的方法来实现,有什么特点. 由于iOS是兼容C语言的.所以C语言里面的最最常见的for循环遍历是没有问题的. 本文中用的数组是获取的系统的语言数组,大约有30多个数据.尽管还不够模拟大批量的数据.但对于方法的验证是没有问题的了. NSArray *langArray = [[NSUserDefaults standardUserDefaults] arrayForKey:@"AppleLanguages"]; 第一种方

iOS中数组的排序方法

1函数介绍与实例 函数一:- (void)sortUsingSelector:(SEL)comparator; 适用于数组中的元素自带比较函数时: 数组排序函数,调用该函数的对象为数组,comparator是调用该函数的数组中的元素的方法.函数参数类型为数组中的元素类型或者id类型,在调用时不需要传递参数,排序过程不可见,该函数执行时:循环取出各个元素,进行比较,然后放到合适的位置 使用实例: 将数组中的元素按照字符串大小排序: NSMutableArray*array = [[NSMutabl

iOS中 三种随机数方法详解

ios 有如下三种随机数方法: 1 2 3 4 5 6 7 8 9 10 //第一种 srand((unsigned)time(0)); //不加这句每次产生的随机数不变 int i = rand() % 5; //第二种 srandom(time(0)); int i = random() % 5; //第三种 int i = arc4random() % 5 ; 注: ① rand()和random()实际并不是一个真正的伪随机数发生器,在使用之前需要先初始化随机种子,否则每次生成的随机数一

IOS中UIAlertView(警告框)常用方法总结

一.初始化方法 - (instancetype)initWithTitle:(NSString *)title message:(NSString*)message delegate:(id /*<UIAlertViewDelegate>*/)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...; 这个方法通过设置一个标题,内容,

iOS中信息交互 通知方法传值

1.定时器 [NSTimer scheduledTimerWithTimeInterval:多长时间变动一次 target:谁的计时器 selector:@selector(方法名) userInfo:定时器信息 repeats:是否重复] 如图,表示每1秒变动一次,给自己设定的计时器,调用下面的timerAc,描述为空,重复 2.通知 [[NSNotificationCenter defaultCenter]postNotificationName:@”通知名”object:通知设立者 use