UIActionSheet是iOS开发中实现警告框的重要的类,在很多情况下都要用到,先来一睹其芳容:
实现步骤如下:
一、为了让控制器类充当操作表的委托,控制器类需要遵从UIActionSheetDelegate协议。
@interface UIActionSheetDemoViewController : UIViewController <UIActionSheetDelegate>{
}
二、生成UIActionSheet并显示。
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"Are you sure?"
delegate:self
cancelButtonTitle:@"No way!"
destructiveButtonTitle:@"Yes, I'm sure."
otherButtonTitles:@"Button One", @"Button Two", nil];
[actionSheet showInView:self.view];
[actionSheet release];
三、点击按钮后的事件。
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"%i", buttonIndex);
if (buttonIndex == actionSheet.cancelButtonIndex) {
return;
}
switch (buttonIndex) {
case 0: {
NSLog(@"Item 1 Selected");
break;
}
case 1: {
NSLog(@"Item 2 Selected");
break;
}
case 2: {
NSLog(@"Item 3 Selected");
break;
}
}
}
点击此处下载示例。
分享到:
相关推荐
Android 仿iPhone UIActionSheet控件效果很好用类似qq上传头像前的选择控件
iPhone开发之UIActionSheet
iPhone开发之UIActionSheet
UIActionSheet demo23456789
UIActionSheet示例代码,IOS 开发总结
高仿微信ActionSheet,使用和UIActionSheet基本相同,代码有不足,仅供参考。
IOS自定义UIActionSheet的例子,供大家学习
ios应用源码之仿uialertview和uiactionsheet的一个效果
ActionSheetPicker = UIPickerView + UIActionSheet
当用户将要进行的操作具有一定危险时,常常使用Action Sheet对用户进行危险提示,这样,用户有机会进行取消操作。 Alert相当于Windows中的Messagebox,跟Action Sheet也是类似的。不同的是,Alert可以只有一个选择项...
UIAlertView,UIActionSheet,UIAlertController封装,一句代码即可,iOS任何系统都可以使用 软件开发设计:PHP、QT、应用软件开发、系统软件开发、移动应用开发、网站开发C++、Java、python、web、C#等语言的项目...
多功能选择器UIActionSheet,仿微信ActionSheet,还有其他样式改变,满足各种需求
详细讲解UIAlertView和UIActionSheet的使用方法,以及开发中遇到的一些问题
自从我第一次在应用中使用UIActionSheet或者UIAlertView时,我不喜欢它的实现方式。 如果在同一类中有两种警报,那么就很痛苦了,例如通过调用委托方法来完成所有。 我也不喜欢在按钮的事件中应该执
简单的自定义UIActionSheet
IOS应用源码之仿UIAlertView和UIActionSheet的一个效果 .rar
一个改变UIActionSheet中按钮的例子,自己以前去试着这样做的时候,一直没成功,这个使用帮了我大忙啊~
详细介绍了UIActionSheet对象的作用,还通过实例详细的讲解了UIActionSheet的用法
整合了UIAlertView和UIActionSheet这两种系统风格的弹框,创建弹框再也不用兼容iOS8以前和iOS8以后了。代码也不会因为delegate而分离,直接接受Block回调。如果您觉得我的代码帮到了您,我会非常欣慰。同时如果您想...
以前在网上下了个时间选择器Demo,由于封装成UIActionSheet类型,而ios8弃用了UIActionSheet和UIAlertView,不得不对代码进行修改。将封装的UIActionSheet改为UIView,为了多态初始化时添加了枚举(几个时间选择器...