UIAlertview的用法(弹出窗口)
来源:互联网 发布:时光知味图片 编辑:程序博客网 时间:2024/06/05 22:30
1. 最简单的用法
UIAlertView*alert =[[UIAlertView
[alert
[alert
2.为UIAlertView添加多个按钮
[alert
[alert
UIAlertView有一个委托UIAlertViewDelegate,继承该委托来实现点击事件
@interface
}
- (void)alertView:(UIAlertView
-(IBAction) buttonPressed;
@end
源文件:
-(IBAction) buttonPressed
{
UIAlertView*alert =[[UIAlertView
[alert
[alert
}
- (void)alertView:(UIAlertView
{
NSString* msg = [[NSString
UIAlertView* alert =[[UIAlertView
[alert
[alert
[msg
}
点击“取消”,“按钮一”,“按钮二”,“按钮三”的索引buttonIndex分别是0,1,2,3
[alertdismissWithClickedButton
5:为UIAlertView添加子视图
在为UIAlertView对象太添加子视图的过程中,有点是需要注意的地方,如果删除按钮,也就是取消UIAlerView视图中所有的按钮的时候,可能会导致整个显示结构失衡。按钮占用的空间不会消失,我们也可以理解为这些按钮没有真正的删除,仅仅是他不可见了而已。如果在UIAlertview对象中仅仅用来显示文本,那么,可以在消息的开头添加换行符(@"\n)有助于平衡按钮底部和顶部的空间。
下面的代码用来演示如何为UIAlertview对象添加子视图的方法。
UIAlertView*alert =[[UIAlertView
[alert
UIActivityIndicatorView*activeView = [[UIActivityIndicatorView
activeView.center
[activeView
[alert
[activeView
[alert
中按照自己的需要修改或添加即可,比如需要将消息文本左对齐,下面的代码即可实现:
-(void)willPresentAlertView:(UIAlertView
{
}
添加其他部件也如出一辙, 如下代码添加两个UITextField:
-(void)willPresentAlertView:(UIAlertView
{
}
UITextField* accoutName =[[UITextFieldalloc]
UITextField* accoutPassword =[[UITextFieldalloc]
accoutName.frame
accoutPassword.frame
accoutName.placeholder
accoutPassword.placeholder
accoutPassword.secureTextEntry
[alertView
[alertView
[accoutName
[accoutPassword
}
对于UIActionSheet其实也是一样的, 在
- (void)willPresentActionSheet:(UIActionSheet*)actionSheet
中做同样的处理一样可以得到自己想要的界面。
- UIAlertview的用法(弹出窗口)
- Swift - 告警框(UIAlertView)的用法
- UIAlertView的用法
- UIAlertView的 用法
- UIAlertView的基本用法
- iOS UIAlertView的用法
- UIAlertView的基本用法
- UIAlertView的简单用法
- (UIAlertView)封装的弹出框和风火轮
- 一组常用的弹出窗口用法总结
- BottomSheetBehavior底部弹出窗口的用法
- 一组常用的弹出窗口用法
- EasyUI 弹出窗口用法
- 系统UIAlertView与代码弹出的区别
- UIAlertView弹出框的简单使用
- iOS求生之路(三)(UIAlertView的用法)
- 一组常用的弹出窗口用法总结(转贴)
- android-电话窗口弹出以及LayoutInflater和inflate的用法
- iOS 导航条(navigation)
- iOS中UIScrollView属性
- iOS中ARC和非ARC混用
- 读取网络图片
- NetWorking(网络)
- UIAlertview的用法(弹出窗口)
- 如何隐藏键盘和文本框偏离
- iOS中使用GDataXML解析XML文…
- IOS中Json解析的四种方法
- iOS中瀑布流的添加
- ubuntu 12.04安装经典的Gnome桌面
- UITextview详解
- uitextview的边框添加圆角
- 关于WEBVIEW的一些小DEMO