• 在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. 如何破解linux用户帐号密码二

    转载 0x01 前言: 今天拿了个linux的主机,提下来了,以前提成root之后就没深入过,这次想着先把root密码破解出来: 以前交洞的时候只是单纯证明存在/etc/passwd和/etc/sha ...

  2. WPF文字渲染相关的问题及解决

     wpf中常常遇到各种和文字渲染有关的问题. 如今列举下现象和解决方式. (1) 现象: 文字大小不一.不在同一水平线. 不同字渲染成同一个字, 或者字体发虚 原因:微软雅黑字体对中文字符的渲染支 ...

  3. 海量数据插入数据库效率对照測试 ---ADO.NET下SqlBulkCopy()对照LINQ 下InsertAllOnSubmit()

    摘要:使用.NET相关技术向数据库中插入海量数据是经常使用操作.本文对照ADO.NET和LINQ两种技术.分别使用SqlBulkCopy()和InsertAllOnSubmit()方法进行操作. 得出 ...

  4. 《学习bash》笔记--调试shell程序

    在shell中,最简单的调试助手时输出语句echo,能够通过把很多echo语句放到代码中进行调试,但必须花费足够的时间以定位 要查看的信息.可能必须通过很多的输出才干发现要查找的信息. 1.set选项 ...

  5. Android Canvas之Path操作

    接上篇,Android自己定义View工具:Paint&Canvas(二) 上一篇中介绍的Canvas绘制图形仅仅能画一些常规图形(圆.椭圆.矩形等),假设想绘制更复杂的图形.Path神器来了 ...

  6. 如何在cmd中启动redis

    首先要指定redis安装的目录,然后输入: redis-server.exe redis.windows.conf 如果成功,则会出现redis的标志,失败的话 请转帖到: http://www.cn ...

  7. Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: Connect

    Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: Connect ...

  8. Node.js下载及安装

    Node.js是一个基于Chrome JavaScript运行时建立的平台, 用于方便地搭建响应速度快.易于扩展的网络应用. Node.js 使用事件驱动, 非阻塞I/O 模型而得以轻量和高效,非常适 ...

  9. 看完这篇再不会 View 的动画框架,我跪搓衣板

    引言 众所周知,一款没有动画的 app,就像没有灵魂的肉体,给用户的体验性很差.现在的 android 在动画效果方面早已空前的发展,1.View 动画框架 2.属性动画框架 3.Drawable 动 ...

  10. 安装部署Solrcloud

    实验说明: 三台虚拟机做solrcloud集群                            安装solr前请确保jdk .tomcat.zookeeper已安装好,否则无法启动 三台虚拟机I ...