UIAlertView 简单介绍

1.实例化

    UIAlertView *view=[[UIAlertView alloc]initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"other", nil];

    如果需要监听弹出以后的点击事件,需要设置代理   UIAlertViewDelegate

2.常用属性

   可以设置弹出为输入框,如下属性

    [view setAlertViewStyle:UIAlertViewStylePlainTextInput];

    UITextField *t1=[view textFieldAtIndex:0];

    UITextField *t2=[view textFieldAtIndex:1];

    t1.keyboardType=UIKeyboardTypeNumberPad;

    t2.keyboardType=UIKeyboardTypeNumbersAndPunctuation;

    [view addButtonWithTitle:@"Test"];

    [view cancelButtonIndex];

    [view firstOtherButtonIndex];

 

3.代理方法

#pragma mark   --UIAlertViewDelegate--

 

//根据被点击按钮的索引处理点击事件

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

{

    NSLog(@"%ld",(long)buttonIndex);

    NSString *login=  [alertView textFieldAtIndex:0].text;

    //NSString *pwd=[alertView textFieldAtIndex:1].text;

    NSLog(@"%@.....",login);

}

 

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex

{

//AlertView已经消失时执行的事件

}

-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex

{

//ALertView即将消失时的事件

}

- (void)alertViewCancel:(UIAlertView *)alertView

{

//AlertView的取消按钮的事件 (Home按钮)

}

-(void)didPresentAlertView:(UIAlertView *)alertView

{

   //AlertView已经显示时的事件

}

-(void)willPresentAlertView:(UIAlertView *)alertView

{

//AlertView即将显示时

}

转载于:https://www.cnblogs.com/iOS-Code/p/4690547.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值