IOS控件AlertView的使用
来源:互联网 发布:360云计算 编辑:程序博客网 时间:2024/05/23 12:05
http://www.idev101.com/code/User_Interface/UIAlertView.html
Alert views are pop-up views that appear over the current view on the iPhone.
Creating and showing an alert (ARC compatible):
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"Do you really want to reset this game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; // optional - add more buttons: [alert addButtonWithTitle:@"Yes"]; [alert show];
For non-ARC (retain/release) projects, you must autorelease the alert view:
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"Do you really want to reset this game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] autorelease]; // optional - add more buttons: [alert addButtonWithTitle:@"Yes"]; [alert show];
If you add the UIAlertViewDelegate protocol to your controller, you can also add the following method which is called after the user dismisses the alert view:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { // do stuff }}
Button indices start at 0 (for the cancelButton specified in the alloc/init), and go up by 1 for each addButtonWithTitle call you add. If you have a lot of alerts, your didDismiss method can keep track of which one is being dismissed if you add the setTag call to the alert initialization: [alert setTag:23];
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:@"I'm sorry Dave, I'm afraid I can't do that." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease]; [alert setTag:12]; [alert show];... later ...- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if ([alertView tag] == 12) { // it's the Error alert if (buttonIndex == 0) { // and they clicked OK. // do stuff } }}
Additional References
- IOS控件AlertView的使用
- ios学习之alertView的基本使用
- Actionsheet和AlertView的使用
- ios alertView
- [ios专项]IOS控件AlertView简单程序_object c
- IOS中自动关闭的AlertView
- ios——带文本框的alertView
- iOS开发之使用画板和CA自定义有动画效果的AlertView
- IOS学习 Block语法的使用:Button、AlertView监听方法改写
- iOS_11_tableViewCell的使用alertView修改数据
- IOS AlertView 自动消失
- ios 自定义alertview
- IOS AlertView 自动消失
- iOS AlertView、ActionSheet
- iOS自定义AlertView
- ios自定义AlertView
- iOS 仿安卓弹框 alertview
- iOS定制AlertView
- 基于测试的项目进度管理(译文)
- oracle 中如何定位重要(消耗资源多)的SQL
- 黑马程序员——04Java各种排序方法和进制转换
- 通过Linux理解操作系统(五):内存管理(中)
- 深刻理解Python中的元类(metaclass)
- IOS控件AlertView的使用
- leetcode:Surrounded Regions
- JSP技术的发展趋势
- HTML URL编码参考
- EXTJs学习笔记(知识点总结)
- eclipse 插件
- 自定义进度条
- 内存对齐及大小端
- servlet入门实例:servlet验证登录用户名和密码