本文主要是介绍iOS UIActionSheet提示框,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
之前做过一个项目使用最新的提示框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:selfcancelButtonTitle:@"取消"destructiveButtonTitle:nilotherButtonTitles:@"照相机",@"摄像机",@"本地相簿",@"本地视频",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中做相应的操作即可
这篇关于iOS UIActionSheet提示框的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!