IOS开发之UI——UIAlertView使用
2014-11-03 15:37
435 查看
首先,视图控制器必须得实现协议UIAlertViewDelegate中的方法,并指定delegate为self,才能使弹出的Alert窗口响应点击事件。
具体代码如下:
ViewController.h中的代码如下:
在点击事件中,添加如下代码即可弹出UIAlertView。
确定取消的事件,重写如下方法:
这个控件比较简单。只是贴点代码记录一下而已。
具体代码如下:
ViewController.h中的代码如下:
#import <UIKit/UIKit.h> @interface ViewController : UIViewController<UIAlertViewDelegate> @end
在点击事件中,添加如下代码即可弹出UIAlertView。
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"主意", nil) message:NSLocalizedString(@"你确定要删除记录吗?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"确定", nil) otherButtonTitles:NSLocalizedString(@"取消", nil),nil]; [alert show]; [alert release];
确定取消的事件,重写如下方法:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex; { int tag = buttonIndex; if (tag == 0) { [arearecode removeAllObjects]; [timerecode removeAllObjects]; [happenrecode removeAllObjects]; [self showhappenview]; }else{ return ; } }
这个控件比较简单。只是贴点代码记录一下而已。
相关文章推荐
- iOS开发UI篇章使用UItableview完成一个简单的QQ好友列表(一)
- iOS开发UI基础—19UITableview控件基本使用
- iOS开发UI基础—32直接使用UITableView Controller
- iOS开发UI基础—31在UITableview的应用中使用动态单元格来完成app应用程序管理界面的搭建
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- IOS开发之UI——UIActivityIndicatorView的详细使用
- IOS开发UI基础 UIAlertView的属性
- [iOS开发]UISplitViewController的使用
- iOS开发之有趣的UI—— UITableView控件基本使用
- iOS开发UI系列之UIImageView的基本使用
- Objective-C ,ios,iphone开发基础:UIAlertView使用详解
- IOS开发:UIAlertView使用
- iOS开发UI基础—27使用UItableview完成一个简单的QQ好友列表(一)
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- iOS开发 点菜系统 使用UIPickerView
- IOS开发:UIAlertView使用
- iOS开发UI基础—25UITableview控件使用小结
- IOS开发:UIAlertView使用
- 【IOS 开发学习总结-OC-47】★ios开发之UI控件——UIAlertView与 UIActionSheet
- ioS开发之UI基础--UIScrollView的基本使用