免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1812 | 回复: 1
打印 上一主题 下一主题

UIActionSheet操作表单-IOS开发 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-03-05 21:39 |只看该作者 |倒序浏览
UIActionSheet操作表单-IOS开发
  1. 01.UIActionSheet* mySheet = [[UIActionSheet alloc]

  2. 02.                           initWithTitle:@"ActionChoose"

  3. 03.                           delegate:self

  4. 04.                           cancelButtonTitle:@"Cancel"

  5. 05.                           destructiveButtonTitle:@"Destroy"

  6. 06.                           otherButtonTitles:@"OK", nil];

  7. 07.    [mySheet showInView:self.view];
  8. 复制代码
复制代码
与UIAlertView类似,我们也是在委托方法里处理按下按钮后的动作。记得在所委托的类加上UIActionSheetDelegate。
  1. 01.- (void)actionSheetCancel:(UIActionSheet *)actionSheet{

  2. 02.    //

  3. 03.}

  4. 04.- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

  5. 05.    //

  6. 06.}

  7. 07.-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{

  8. 08.    //

  9. 09.}

  10. 10.-(void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex{

  11. 11.    //

  12. 12.}
  13. 复制代码
复制代码
看到那个红色的按钮没?那是ActionSheet支持的一种所谓的销毁按钮,对某户的某个动作起到警示作用,比如永久性删除一条消息或者日志。如果你指定了一个销毁按钮他就会以红色高亮显示:
  1. 01.mySheet.destructiveButtonIndex=1;  
  2. 复制代码
复制代码
与导航栏类似,操作表单也支持三种风格 :
  1. 01.UIActionSheetStyleDefault              //默认风格:灰色背景上显示白色文字  

  2. 02.UIActionSheetStyleBlackTranslucent     //透明黑色背景,白色文字  

  3. 03.UIActionSheetStyleBlackOpaque          //纯黑背景,白色文字  
  4. 复制代码
复制代码
用法用例:mySheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;显示ActionSheet有三种方法:1.在一个视图内部显示,可以用showInView[mySheet showInView:self];2.如果要将ActonSheet 与工具栏或者标签栏对齐,可以使用showFromToolBar或showFromTabBar[mySheet showFromToolBar:toolbar];[mySheet showFromTabBar:tabbar];
解除操作表单用户按下按钮之后,Actionsheet就会消失——除非应用程序有特殊原因,需要用户按下做个按钮。用dismiss方法可令表单消失:
  1. 01.[mySheet dismissWithClickButtonIndex:1 animated:YES];  
  2. 复制代码
复制代码

论坛徽章:
0
2 [报告]
发表于 2012-03-05 21:39 |只看该作者
谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP