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

iOS UIActionSheet提示框

2016-03-05 14:45 337 查看
之前做过一个项目使用最新的提示框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中做相应的操作即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: