一、警告视图
1、UIAlertView
作用:提示用户,帮助用户选择。
2、示例代码
实践代码
<pre name="code" class="objc"><span style="font-family: Arial, Helvetica, sans-serif;"> UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];</span>
button1.frame = CGRectMake(10, 100, 140, 40); [button1 setTitle:@"alertView" forState:UIControlStateNormal]; [button1 addTarget:self action:@selector(showAlertView) forControlEvents:UIControlEventTouchUpInside]; [self.window addSubview:button1]; UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button2.frame = CGRectMake(240-70, 100, 140, 40); [button2 setTitle:@"actionSheet" forState:UIControlStateNormal]; [button2 addTarget:self action:@selector(showActionView) forControlEvents:UIControlEventTouchUpInside]; [self.window addSubview:button2]; UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles:@"other", nil]; [alertView show]; return YES;}-(void)showAlertView{ UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles:@"other", nil]; [alertView show];}-(void)showActionView{ UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"title" delegate:nil cancelButtonTitle:@"cancel" destructiveButtonTitle:@"destructive" otherButtonTitles:@"other1", nil];}