您的位置:首页 > 产品设计 > UI/UE

iOS开发基础 - UIActionSheet

2012-04-18 00:05 351 查看
UIActionSheet是一个非常常用的UIView,可以放置多个操作按钮并通过UIActionSheetDelegate委托实现一些方法。在这里只是一些基本简单的应用和讲解,以后如果遇到更深层次的应用将会补充上。

2012-4-28



Apple官网文档地址: UIActionSheet Class ReferenceUIActionSheetDelegate Protocol Reference

例子:可以在一个消息中,创建一个UIActionSheet

UIActionSheet *actT=[[UIActionSheet alloc] initWithTitle: @"title"
delegate: self
cancelButtonTitle: @"Cancel"
destructiveButtonTitle: @"ImageFormAlbum"
otherButtonTitles: @"ImageFomrCamera",nil];//创建一个UIActionSheet对象
[actT setActionSheetStyle:UIActionSheetStyleBlackTranslucent];//设置ActionSheetStyle
[actT showInView:self.appMy.skRt.view];//将UIActionSheet对象添加父视图中
[actT release];


通常在使用UIActionSheet过程中需要使用UIActionSheetDelegate委托,一般需要实现- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;这个方法。

#pragma mark -
#pragma mark UIActionSheet
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
switch (buttonIndex) {
case 0:{
//To do something

}
break;
case 1:{
              //To do something

}
break;
default:
break;
}
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: