UIAlertView警报-IOS开发
2012-03-12 00:00
399 查看
UIAlertView* myAlert = [[UIAlertView alloc] initWithTitle:@"sorry" message:@"1234567890" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; myAlert.delegate = self; [myAlert show]; //[myAlert release];//如果未在下面的委托中release的话记得要在这里release,否则内存泄漏了这里设置delegate有啥用出,加入我们仅仅是只要显示一个弹窗警告,而不采取其他动作我们可以安全用如下代码解决:
[[[[UIAlertView alloc] initWithTitle:@"sorry" message:@"1234567890" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease] show];
设置委托有啥作用呢?我们可以实现UIAlertView的一个委托方法,让后可以在这个方法里处理按下按钮后的动作,根据用户按下的哪个按钮来决定进行射门样的操作,比如按下OK按钮与按下Cancel按钮的后要进行的操作必然有可能不同:
-(void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"Button %d pressed",buttonIndex); [alertView release]; }
看到否?我们可以通过buttonIndex来判断用户按下了哪个按钮,然后来进行相应处理,同时我们还可以在这里面release,因为我们在上面的代码中可能不确定需要在哪里release,所以在按下按钮后release是不是最安全的呢?
$(document).ready(function(){dp.SyntaxHighlighter.HighlightAll('code');});
原文链接:
http://blog.csdn.net/iukey/article/details/7295581
相关文章推荐
- UIAlertView警报-IOS开发
- UIAlertView警报-IOS开发
- iOS开发之UIAlertview的事件处理
- ios开发之改变UIAlertView背景图片
- iOS开发之UIalertView
- iOS开发:UIAlertView使用的问题
- UIAlertView和UIActionSheet 分类: ios开发 2015-04-09 20:43 152人阅读 评论(0) 收藏
- iOS开发之用block来实现UIAlertView点击事件的代理方法
- 学习IOS开发UI篇--UIAlertView/UIActionSheet
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- IOS开发中UIAlertView与UIAlertController的用法
- Iphone开发(六)IOS中的通知--操作表ActionSheet和警报AlertView
- (iOS开发)关于IOS9以后UIAlertView被UIAlerTController取代的有关问题
- Iphone开发(六)IOS中的通知--操作表ActionSheet和警报AlertView
- iOS开发 对话框UIActionSheet和UIAlertView用法
- IOS开发基础篇之UIAlertView的使用
- IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- iOS开发Debug之UIAlertViewController在iPad弹出崩溃问题
- iOS开发-ios7 UIAlertView自定义
- 【IOS 开发】基本 UI 控件详解 (UISegmentedControl | UIImageView | UIProgressView | UISlider | UIAlertView )