• 在iphone和ipad上使用UIActionShee控件t的效果会不一样,在苹果的官方文档中有相关说明:

在ipad上使用UIActionSheet控件改控件不再从底部弹出,而是从屏幕中间弹出与UIAlertView警告框弹出有点类似。效果如图所示,cancelButton按钮文字显示不出来,destructiveButtonTitle按钮文字为红色加粗字体。

  • iOS 8.3以后不再使用actionsheet,而是统一用UIAlertController,所以如果有iOS7的用户,需要适配:
        //初始化actionsheet,适配 iOS 8.3 以下

        if([[UIDevice currentDevice].systemVersion floatValue] > 8.3){//iOS 8.3以上,废弃旧版actionsheet
UIAlertController* actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *sendAction = [UIAlertAction actionWithTitle:@"发送Log文件给微信好友" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self SendLogToWechatFriends];
}];
[actionSheet addAction:sendAction];
actionSheet.popoverPresentationController.sourceView = _logoImgView;
actionSheet.popoverPresentationController.sourceRect = _logoImgView.bounds;
[actionSheet.popoverPresentationController setPermittedArrowDirections:UIPopoverArrowDirectionUp]; [self presentViewController:actionSheet animated:YES completion:nil];
}else{//iOS 8.3以下使用旧版actionsheet
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:nil
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"发送Log文件给微信好友",nil];
actionSheet.actionSheetStyle = UIBarStyleDefault;
actionSheet.delegate = self;
[actionSheet showFromRect:[_logoImgView frame] inView:self.view animated:YES];
}
  • 为了避免适配,使用自定义的popovercontrolller,然后嵌入一个包着button的viewcontroller:
        UIViewController* actionSheet = [[UIViewController alloc]init];
actionSheet.view.backgroundColor = [UIColor clearColor]; // UILabel* label = [[UILabel alloc]initWithFrame:CGRectMake((self.view.bounds.size.width-50)/4, 0, self.view.bounds.size.width-50, 50)];
// label.text = @"发送Log文件给微信好友";
// label.textColor = MttColorNamed(@"browser_startpage_news_category_color");
// [actionSheet.view addSubview:label]; UIButton* btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width-50, 50)];
btn.backgroundColor =[UIColor clearColor];
[btn setTitle:@"发送Log文件给微信好友" forState:UIControlStateNormal];
btn.titleLabel.textAlignment = NSTextAlignmentCenter;
[btn setTitleColor:MttColorNamed(@"browser_startpage_news_category_color") forState:UIControlStateNormal];
[btn addTarget:self action:@selector(SendLogToWechatFriends) forControlEvents:UIControlEventTouchUpInside];
[actionSheet.view addSubview:btn]; MttPopoverController *popController = [[MttPopoverController alloc] initWithContentViewController:actionSheet];
popController.popoverContentSize = CGSizeMake(self.view.bounds.size.width-50, 50);
//popController.delegate = self;
[popController presentPopoverFromRect:_logoImgView.frame inView:self.view permittedArrowDirections:WYPopoverArrowDirectionUp animated:YES];
self.popoverController = popController;
  • button在设置title颜色的时候,注意状态,“|”的意思是and,不是或

更多关于actionsheet,参考http://www.jianshu.com/p/4d1ca0d9a6f1

iPad actionsjeet的更多相关文章

  1. ipad&mobile通用webapp框架前哨战

    响应式设计的意义 随着移动设备的发展,移动设备以迅猛的势头分刮着PC的占有率,ipad或者android pad的市场占有率稳步提升,所以我们的程序需要在ipad上很好的运行,对于公司来说有以下负担: ...

  2. ipad和iphone的适配

    关于xib或者storybord下iphone的横竖屏的适配以及ipad的适配 ios8出现了Size Classes,解决了各种屏幕适配的问题,他把屏幕的宽和高分别分成了三种,把屏幕总共分成了九种情 ...

  3. Xcode will continue when iPad is finished. "Could not find Developer Disk Image"

    1:  Xcode will continue when iPad is finished. 等待进度条读取完成即可: 2: xcode,安装新版本的iOS 的 xcode 支持文件 的路径: /ap ...

  4. iPhone/iPad/Android UI尺寸规范 UI尺寸规范,UI图标尺寸,UI界面尺寸,iPhone6尺寸,iPhone6 Plus尺寸,安卓尺寸,iOS尺寸

    iPhone/iPad/Android UI尺寸规范 UI尺寸规范,UI图标尺寸,UI界面尺寸,iPhone6尺寸,iPhone6 Plus尺寸,安卓尺寸,iOS尺寸 iPhone界面尺寸 设备 分辨 ...

  5. iPad编程

    1. iPad 现有型号: iPad Pro, iPad Air, iPad mini 均配备Retina显示屏.早期还有iPad 依次对应的坐标系及分辨率: iPad Pro 坐标系:1366 x ...

  6. 在Mac电脑上为iPhone或iPad录屏的方法

    在以前的Mac和iOS版本下,录制iPhone或者iPad屏幕操作是一件稍微复杂的事情.但是随着Yosemite的出现,在Mac电脑上为iPhone或iPad录屏的方法就变得简单了.下面就介绍一下具体 ...

  7. ipad

    1. ipad pro 与 ipad air2 时间已经是2016.12.9, 苹果还没有推出新的ipad产品,有些纠结于哪款更适合自己,总结下产品不易获取的核心配置信息 ipad air2 ram ...

  8. 媒体查询判断ipad和iPhone各版本

    /* 判断ipad */ @media only screen and (min-device-width : 768px) and (max-device-width : 1024px){ /* s ...

  9. iPad版微信终于来临了 微信5.4版搜索更智能 转账就是发消息

    等待甚久的iPad版微信终于来临了!昨日微信iOS版本更新至5.4.0.16,新增功能包括搜索公众号.识别图中二维码.面对面收钱,同时适配iPad.(微信5.4安卓版重回ios风格 导航菜单都放底栏位 ...

随机推荐

  1. HDU 3591 The trouble of Xiaoqian(多重背包+全然背包)

    HDU 3591 The trouble of Xiaoqian(多重背包+全然背包) pid=3591">http://acm.hdu.edu.cn/showproblem.php? ...

  2. js 数组去重复

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. 2017.04.20 Adams仿真介绍

    Adams 仿真 | 验证"隐性机器人模型"概念,提高视觉伺服精度 产品:Adams行业:科研优势: 1.Adams 仿真可精确预测机器人的位置和方位 2.仿真在理论工作验证中起着 ...

  4. HDU 4927 大数

    题意非常easy: 对于长度为n的数.做n-1遍.生成的新数列: b1=a2-a1   b2=a3-a2  b3=a4-a3 c1=b2-b1   c2=b3-b2 ans=c2-c1 最后推出公式: ...

  5. F - 概率(经典问题)

    Description Sometimes some mathematical results are hard to believe. One of the common problems is t ...

  6. Shiro学习(7)与Web整合

    Shiro提供了与Web集成的支持,其通过一个ShiroFilter入口来拦截须要安全控制的URL.然后进行对应的控制,ShiroFilter相似于如Strut2/SpringMVC这样的web框架的 ...

  7. Shell脚本值:运算符

    算术运算符 原生bash不支持简单的数学运算,但是可以通过其他命令来实现,例如 awk 和 expr,expr 最常用. expr 是一款表达式计算工具,使用它能完成表达式的求值操作. 例如:实现两个 ...

  8. webstrom 应用 转(http://blog.csdn.net/zghekuiwu/article/details/54382145)

    WebStorm 是 JetBrains 推出的一款商业的 JavaScript 开发工具 任何一个编辑器都需要保存(ctrl + s),这是所有win平台上编辑类软件的特点,但是webstorm编辑 ...

  9. dos下连接mysql,显示表结构

    C:\Windows\system32>mysql -hlocalhoset -uroot -p Enter password: ***** mysql> use ssh Database ...

  10. 利用window.navigator.userAgent判断当前是否微信内置浏览器

    <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="utf-8&quo ...