之前做过一个项目使用最新的提示框4s会默然的崩溃,于是又修改成最原始的UIActionSheet
UIActionSheet使用情况具体如下
#import "ViewController.h"
@interface ViewController ()<UIActionSheetDelegate>
@property (nonatomic, strong)UIButton *button;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.button = [[UIButton alloc]init];
self.button.frame = CGRectMake(100, 100, 50, 30);
self.button.backgroundColor = [UIColor redColor];
[self.button addTarget:self action:@selector(clicks:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.button];
}
- (void)clicks:(UIButton *)button {
UIActionSheet* actionSheet = [[UIActionSheet alloc]
initWithTitle:@"请选择文件来源"
delegate:self
cancelButtonTitle:@"取消"
destructiveButtonTitle:nil
otherButtonTitles:@"照相机",@"摄像机",@"本地相簿",@"本地视频",nil];
[actionSheet showInView:self.view];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 0:
{
NSLog(@"2");
}
break;
case 1:
{
NSLog(@"2");
}
break;
case 2:
{
NSLog(@"2");
}
break;
case 3:
{
NSLog(@"4");
}
break;
default:
break;
}
}
在对应的case中做相应的操作即可