Objective-C-iOS常用小控件(UIAlertView)警告框
来源:互联网 发布:端口共享 编辑:程序博客网 时间:2024/03/29 05:21
这里需要说明一下:从iOS9.0以后,苹果不再提倡用UIAlertView了,如果你非要用,也是可以的
//UIAlertView警告视图
- (void)createAlertView{
//创建警告框
UIAlertView *alertView = [[UIAlertViewalloc] init];
UIAlertView *alertView1 = [[UIAlertViewalloc] initWithTitle:@"标题"message:@"副标题"delegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"确定",nil];
//警告框的标题
alertView.title =@"输入用户名和密码";
//设置警告框的风格
alertView.alertViewStyle =UIAlertViewStyleDefault;//系统默认
alertView.alertViewStyle =UIAlertViewStyleSecureTextInput;//带密码输入框
alertView.alertViewStyle =UIAlertViewStylePlainTextInput;//带普通文本输入框
alertView.alertViewStyle =UIAlertViewStyleLoginAndPasswordInput;//带用户名和密码输入框
//设置警告框的按钮
[alertView addButtonWithTitle:@"取消"];
[alertView addButtonWithTitle:@"确定"];
//设置警告框的代理
alertView.delegate =self;
//按钮的个数
NSInteger nums = alertView.numberOfButtons;
//取消按钮的下标
NSInteger cancelIndex = alertView.cancelButtonIndex;
//其它按钮中,第一个按钮的下标
NSInteger otherIndex = alertView.firstOtherButtonIndex;
//展示警告框
[alertView show];
//点击取消按钮时让警告框消失
//- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
}
//代理方法
// 点击了那一个按钮
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
{
UITextField *nameText = [alertViewtextFieldAtIndex:0];
UITextField *passwordText = [alertViewtextFieldAtIndex:1];
NSLog(@"name:%@ pass:%@",nameText.text,passwordText.text);
}
- Objective-C-iOS常用小控件(UIAlertView)警告框
- Swift-iOS常用控件(UIAlertView警告视图)
- Objective-C-iOS常用小控件(UISwitch)
- Objective-C-iOS常用小控件(UIActivityIndicatorView)
- Objective-C-iOS常用小控件(UISlider)
- Objective-C-iOS常用小控件(UISegmentedControl)
- Objective-C-iOS常用小控件(UIProcessView)进度条
- IOS UIAlertView(警告框)方法总结
- Objective-C-iOS常用小控件(UIActionSheet )动作列表
- IOS中UIAlertView(警告框)常用方法总结
- Objective-C-iOS常用小控件(UIStepper)计数器/步进器
- [iOS] iPhone常用控件、UIActionSheet、UIAlertView
- UIAlertView -(警告框)方法总结
- UIAlertView/警告框
- UIAlertView 警告框
- UIAlertView(警告提示)
- Objective-C ,ios,iphone开发基础:UIAlertView使用详解
- iOS控件之UIAlertView
- 血的教训···········复用那些事
- tomcat跑到一半不动了
- IOS 核心动画之CAKeyframeAnimation
- 自定义TabBar条,实现重写TabBar的TabBarItem,然后在中间额外加一个按钮
- Ajax学习笔记
- Objective-C-iOS常用小控件(UIAlertView)警告框
- Activity的setContentView()方法源码分析
- 手掌与拳头检测
- (0003) iOS 开发之App 适配iOS 10
- sparksql基础应用
- 使用ajax和window.history.pushState无刷新改变页面内容和地址栏URL
- 软件工程
- 构建ng2简单练手
- 主线程和子线程中的消息循环