Iphone之UIAlertView和UIActionSheet
2012-03-12 16:35
302 查看
UIAlertView和UIActionSheet的用法很简单,直接看代码:
1.UIAlertView:
.h头文件:
.m文件中的方法:
.h头文件:
1.UIAlertView:
.h头文件:
#import <UIKit/UIKit.h> @interface DialogControl : UIViewController<UIAlertViewDelegate> {//注意要实现这个协议 UIAlertView *alertView1;//多个dialog的点击事件需要区分是哪一个dialog UIAlertView * al; } -(IBAction) showDialog; -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;//重写点击事件方法 @end
.m文件中的方法:
//点击界面上的一个button促发的方法 -(IBAction)showDialog{ alertView1 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"注意增加一个确定按钮的点击事件" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; [alertView1 show]; //[alertView release]; } //重写协议中对话筐按钮点击事件方法 -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (alertView == alertView1) { if (buttonIndex == 1) { al = [[UIAlertView alloc]initWithTitle:@"提示" message:@"你按下了确定按钮" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [al show]; } } else if(alertView == al){ if (buttonIndex == 0) { NSLog(@"你点击了确定按钮"); } } }2.UIActionSheet:
.h头文件:
#import <UIKit/UIKit.h> @interface OtherView : UIViewController<UIActionSheetDelegate> {//注意实现这个协议 } @end.m文件的方法:
//进入页面就调用的方法,进入页面就弹出 -(void) viewDidAppear:(BOOL)animated{ UIActionSheet *actionSeet = [[UIActionSheet alloc]initWithTitle:@"选择事件" delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"destructivebutton" otherButtonTitles:@"one",@"two",@"three", nil]; [actionSeet showInView:self.view]; [actionSeet release]; } //重写协议中actionsheet中按钮点击方法 -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"%d",buttonIndex); }
相关文章推荐
- Iphone之UIAlertView和UIActionSheet
- iPhone起步-2:iPhone常用控件、UIActionSheet、UIAlertView (转)
- iPhone起步-2:iPhone常用控件、UIActionSheet、UIAlertView (转)
- iphone开发 UIActionSheet(操作表) 和UIAlertView(警告)的用法
- 【iPhone代码片段之一】UIActionSheet&UIAlertView的应用
- UI控件篇——UIActionSheet(操作表)和UIAlertView(警告框)
- 介绍UIALertView和UIActionSheet的用法。
- UI29_UIAlertAction(UIAlertView和UIActionSheet的结合体)
- IOS UIAlertController 弹框 (ios 9.0 后代替了UIAlertView弹框 和 UIActionSheet下弹框)
- UIAlertController的使用(ios9.0后代替UIAlertView与UIActionSheet)
- UIAlertView和UIActionSheet
- IOS学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- UIAlertController(UIActionSheet、UIAlertView)
- iOS UIAlertController弹框(OS9.0 后替代UIAlertView弹框和UIActionSheet下弹框)
- 谈谈改变 UIAlertView 和 UIActionSheet 的颜色
- 给UIAlertView UIActionSheet 添加block支持
- iOS开发 提示框- UIAlertController(是UIAlertView和UIActionSheet的合二为一)
- 如何自定义UIActionSheet(UIAlertView)中的内容
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet)
- 学习IOS开发UI篇--UIAlertView/UIActionSheet