首页 技术 正文
技术 2022年11月6日
0 收藏 803 点赞 439 浏览 2990 个字

举例:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@”Default Alert View”message:@”Defalut” delegate:self cancelButtonTitle:@”Cancel” otherButtonTitles:@”OK”, nil];

UIAlertView使用全解
标准的双按钮,cancel那个buttonIndex 为0, ok button 的buttonIndex为1

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@”Default Alert View”message:@”Defalut” delegate:self cancelButtonTitle:@”Cancel” otherButtonTitles:@”OK”,@“ThirdButton”, nil];
UIAlertView使用全解
和程序里的顺序一样,cancel   ok   thirdButton 的buttonIndex 分别为0 1 2

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@”Default Alert View”message:@”Defalut” delegate:self cancelButtonTitle:@”Cancel” otherButtonTitles:@”OK”,@“ThirdButton”, nil];
UIAlertView使用全解

同理,cancel   ok   thirdButton FourthButton的buttonIndex 分别为0 1 2 3

[alertView show];

 

UIAlertView Delegate

– (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndexalertView—>这个不用多说了吧buttonIndex—->从0开始可以通过if (buttonIndex == 1) { } 这样的来控制点击了某个按钮需要做什么操作 – (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex这个方法在动画结束和视图隐藏之后调用 – (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex这个方法在动画开始和视图隐藏之前调用 – (void)alertViewCancel:(UIAlertView *)alertView在视图将要被取消之前例如,用户点击了home键三个函数的调用顺序依次是:alertViewCancel—-》willDismissWithButtonIndex—》didDismissWithButtonIndex – (BOOL)alertViewShouldEnableFirstOtherButton(UIAlertView *)alertViewios 5+设置yes / no  将会设置alertView 的第一个otherButton的enable属性 – (void)didPresentAlertView:(UIAlertView *)alertView在视图提交给用户以后调用 –  (void)willPresentAlertView:(UIAlertView *)alertView在视图提交给用户以前调用 这六个delegate 方法调用的顺序依次是alertViewShouldEnableFirstOtherButton—->willPresentAlertView—>didPresentAlertView—->clickedButtonAtIndex—->(如果会触发视图取消,则会调用alertViewCancel)willDismissWithButtonIndex—->didDismissWithButtonIndex ios4.0以后 alertView不会自动随着程序转向后台而移除alertView属性1.alertViewStyle:UIAlertViewStyleDefault 只弹信息和按钮UIAlertViewStyleSecureTextInput 有一个textfield加密框UIAlertViewStylePlainTextInput 有一个不加密的textfieldUIAlertViewStyleLoginAndPasswordInput 有两个textfield,Login和password 只要有textfield就可以用textfieldAtIndex来捕获并进行相应的操作例如换键盘类型 2.cancelButtonIndex开始是0,如果没有设置cancel button 则是-1 3.delegate如果没有设置则是nil 4.firstOtherButtonIndex从0开始,如果没设置则是-1,而且没被设置则会被忽略 5.message 消息 6.numberOfButtons只读  alertView中的按钮数量 7.title标题 8.visible只读  如果是yes 表示被显示 实例方法- (NSInteger)addButtonWithTitle:(NSString *)title返回值是增加的Button的index – (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex输入buttonIndex 返回button的标题 – (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated程序自动完成点击buttonIndex的button 并dismiss 整个alertView的操作 – (id)initWithTitle:(NSString *)title message:(NSString)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitle:(NSString *)otherButtonTitles, …这个就不用多说了 – (void)show要显示必须要调用这个alertview才会显示 –  (UITextField *)textfieldAtIndex:(NSInteger)textfieldIndex返回值是textfieldUIAlertViewStyleDefault 没有UIAlertViewStyleSecureInput textfieldIndex 只有一个为0UIAlertViewStylePlainInput textfieldIndex 只有一个为0UIAlertViewStyleLoginAndPasswordInput textfieldIndex有两个 0 1

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,083
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,558
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,407
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,180
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,816
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,899