------<a href="http://www.itheima.com" target="blank">Java培训、Android培训、iOS培训、.Net培训</a>、期待与您交流! -------
------<a href="http://www.itheima.com" target="blank">Java培训、Android培训、iOS培训、.Net培训</a>、期待与您交流! -------
1.警告框的应用场景
1.应用不能继续进行时,当功能无法完成时需要给用户一个警告。
2.询问另外的解决方案。比如wifi用不了时用户可以选择蜂窝移动网络。
3.用户授权。比如QQ需要使用位置,需要用户的授权。
2.使用事例
搭建好界面:
写好监听事件代码如下:
- (IBAction)click:(id)sender {
//给UIAlertView分配内存
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"点我"
message:@"小样敢点我"
delegate:self
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes", nil];
//显示UIAlertView
[alertView show];
}
运行如图所示