IOS学习之路二十二(UIAlertView获得文本框内容及添加北京图片)
来源:互联网 发布:古风额饰淘宝 编辑:程序博客网 时间:2024/04/28 00:37
今天写项目要用到警告框带输入框的,于是就自己做了个小demo.
效果图大体如下:
下面简单介绍一下UIAlertView
alertViewStyle属性有以下三种选项:
UIAlertViewStylePlainTextInput添加一个普通输入框 UIAlertViewStyleSecureTextInput 密码输入框 UIAlertViewStyleLoginAndPasswordInput 普通输入框加密码输入框
下面分别来看看这三种属性的效果:
(UIAlertViewStylePlainTextInput) (UIAlertViewStyleSecureTextInput)
(UIAlertViewStyleLoginAndPasswordInput)
下面附上自己写的部分关键代码:
#pragma mark 弹出菜单- (IBAction)showMenu:(id)sender { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"修改Webservice请求地址" message:@"请输入地址:(http://192.168.6.12)" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil]; [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput]; [alertView show]; //背景View UIView *additonBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, alertView.frame.size.width-30, alertView.frame.size.height-20)]; additonBackgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bag3.jpg"]]; //添加背景图片 [alertView insertSubview:additonBackgroundView atIndex:1];}#pragma mark 获得输入框里的值- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex]; if ([buttonTitle isEqualToString:@"确定"]){ UITextField *tf=[alertView textFieldAtIndex:0];//获得输入框 NSString * requestedURL=tf.text;//获得值 }}
转载请注明:
新浪微博:http://weibo.com/u/3202802157
- IOS学习之路二十二(UIAlertView获得文本框内容及添加北京图片)
- iOS学习之动态添加Button和监听UIAlertView按钮
- iOS学习之动态添加Button和监听UIAlertView按钮
- iOS学习之动态添加Button和监听UIAlertView按钮
- iOS学习之动态添加Button和监听UIAlertView按钮
- JSP学习之路(二):设置input标签中,选择自动清除文本框中的内容
- 【学习笔记】IOS(1)之UIAlertView
- iOS开发之如何自定义UIActionSheet(UIAlertView)中的内容
- IOS开发---菜鸟学习之路--(二十二)-近期感想以及我的IOS学习之路
- iOS学习基础学习之动态添加Button和监听UIAlertView按钮
- 【学习ios之路:UI系列】UIAlertView. UIActionSheet 和 UIAlertController
- c++获得文本框内容
- Swift基础(二十二)UIAlertView,UIActionSheet,UIAlertController
- 十二 iOS之 图片擦除
- 十二 iOS之 折叠图片
- angularJS学习之路(二十二)---模块加载---config
- javaee学习之路(二十二)JavaMail
- IOS学习之路十二(UITableView下拉刷新页面)
- JVM调优总结
- 简单概率dp(期望)-hdu-3853-LOOPS
- [C++ Primer] 复制控制
- 查看Oracle中是否有锁表
- C/C++平台、编译器等预判宏
- IOS学习之路二十二(UIAlertView获得文本框内容及添加北京图片)
- ActionContext和ServletActionContext小结
- 二维数组的转置
- jquery validate验证框架与kindeditor使用问题
- 正则表达式的使用
- UI控件之UIButton详解
- Android记录7--开发时会用到显示时间的知识点
- 电子工程师名片——FAT16文件系统
- script难学吗?