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

IOS-49-UIActionSheet在iOS8后已废弃,以下为各版本通用适配办法

2016-01-26 14:57 441 查看
搞了半天,原来UIActionSheet在iOS8后已废弃,怪不得在iPhone5上好好地,iPhone6就废了,一个简单的弹出视图,仿微信的退出登录弹出视图,类似iOS系统的UIActionSheet, 但是UIActionSheetiOS8后废弃, JXAacionSheet将支持6.0以上各个版本,使用也很简单,支持屏幕旋转。

实现效果:



之前的代码是这样的:

UIActionSheet *sheetView = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"立即充电",@"定时充电",@"智能充电(敬请期待)", nil];

[sheetView showInView:[UIApplication sharedApplication].keyWindow];


解决办法:在github上找到一个封装的第三方库,代码实现如下:

JXActionSheet *sheetView = [[JXActionSheet alloc]initWithTitle:nil cancelTitle:@"取消" otherTitles:@[@"立即充电",@"定时充电",@"智能充电(敬请期待)"]];
sheetView.destructiveButtonIndex = 2;
[sheetView showView];
[sheetView dismissForCompletionHandle:^(NSInteger clickedIndex, BOOL isCancel){
if (clickedIndex == 0) {
·············
}
}


demo下载地址:http://download.csdn.net/detail/iot_li/9418380
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: