• 在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. Protel中的快捷键使用(网上资源)

    使用快捷键之前,将输入法切换至中文(中国)状态 Enter——选取或启动 Esc——放弃或取消 F1——启动在线帮助窗 Tab——启动浮动图件的属性窗口 Page Up——放大窗口显示比例 Page ...

  2. js CacheQueue

    (function(){ var CacheQueue=function(name,weightValue,maxLength,clearTimerTime){ //public this.name ...

  3. linux过滤ip段

    https://www.2cto.com/net/201307/227257.html

  4. C# 读取Excel中的数据

    #region 读取Excel中的数据 /// <summary> /// 读取Excel中的数据 /// </summary> /// <param name=&quo ...

  5. ios 视图的旋转及应用

    有时候,需要做出如下图所示的效果,这就需要用到视图的旋转了 1.首先将旋转的值由角度转换为弧度: #define degreesToRadinas(x) (M_PI * (x)/180.0) 注:M_ ...

  6. iphone、ipod Touch、ipad触屏时的js事件

    1.Touch事件简介 pc上的web页面鼠 标会产生onmousedown.onmouseup.onmouseout.onmouseover.onmousemove的事件,但是在移动终端如 ipho ...

  7. 结构体定义:struct与typedef struct

    https://blog.csdn.net/haiou0/article/details/6877718?tdsourcetag=s_pcqq_aiomsg https://blog.csdn.net ...

  8. Struts2学习一----------Struts2的工作原理及HelloWorld简单实现

    © 版权声明:本文为博主原创文章,转载请注明出处 Struts2工作原理 一个请求在Struts2框架中的处理步骤: 1.客户端初始化一个指向Servlet容器(例如Tomcat)的请求 2.这个请求 ...

  9. C语言日期计算器

    记录下码子 # define _CRT_SECURE_NO_WARNINGS # include <stdio.h> # include <stdlib.h> int days ...

  10. Git分支中的远程操作实践

    Git分支中的远程操作实践 前几篇博客陆陆续续的讲了好多关于Git操作的内容, 其中在上篇博客聊了<Git中的merge.rebase.cherry-pick以及交互式rebase>,本篇 ...