文章目录
警告对话框
什么是警告/提示对话框?如下
在手机的使用时经常会出现这样的警告/提示对话框,显示提示或提出警告
警告对话框的定义及使用
首先,在ViewVontroller.h
文件中定义如下的成员变量,及声明如下属性
@interface ViewController : UIViewController<UIAlertViewDelegate> {
//定义一个警告对话框视图对象
UIAlertController* _alert;
}
@property (retain, nonatomic)UIAlertController* alert;
@end
在ViewVontroller.m
文件中进行对警告对话框的定义及使用
先实现属性同步
@implementation ViewController
@synthesize alert = _alert;
@synthesize activityIndicatorView = _activityIndicator;
要想出现一个警告对话框,我们需要有一个按钮UIButton
来触发这个警告对话框
因此先定义按钮UIButton
如下
UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(10, 100 + 100 * i, 100, 40);
[btn setTitle:@"警告对话框" forState:UIControlStateNormal];
并用UIButton
的事件响应函数,添加到视图控制器中
[btn addTarget: