热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

来自Popover的UIActionSheet和iOS8GM。-UIActionSheetfromPopoverwithiOS8GM

AnyoneisgettingthismessagewhiletryingtoshowUIActionSheetfrompopover?有人在从弹出窗口显示UIActionSh

Anyone is getting this message while trying to show UIActionSheet from popover?

有人在从弹出窗口显示UIActionSheet时收到这个消息吗?

Your application has presented a UIAlertController () of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.

您的应用程序提供了一个UIAlertController()样式的UIAlertControllerStyleActionSheet。UIAlertController的modalPresentationStyle就是UIModalPresentationPopover。您必须通过警报控制器的popoverPresentationController为该弹窗提供位置信息。您必须提供sourceView和sourceRect或barButtonItem。如果在显示警报控制器时不知道该信息,可以在UIPopoverPresentationControllerDelegate方法-prepareForPopoverPresentation中提供。

Previously to the GM I used some workaround for converting the UIActionSheet to UIAlertController and this is working fine. However it seems that Apple tried to solve the UIActionSheet issues and I didn't want to use my workaround - but it seems that I have no choice...

之前,我使用了一些变通方法将UIActionSheet转换为UIAlertController,这是正常的。然而,似乎苹果公司试图解决UIActionSheet的问题,我不想用我的解决方案——但似乎我别无选择……

5 个解决方案

#1


100  

To support iPad, include this code:

要支持iPad,包括以下代码:

alertView.popoverPresentationController?.sourceView = self.view
alertView.popoverPresentationController?.sourceRect = self.view.bounds
// this is the center of the screen currently but it can be any point in the view

self.presentViewController(alertView, animated: true, completion: nil)

#2


11  

If you are presenting the action sheet after the user makes a selection on a cell within a UITableView. I found that this works decently well:

如果您是在用户在UITableView中的单元格上进行选择之后显示操作表。我发现这个方法很有效:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Directions" 
                                                               message:@"Select mode of transportation:"
                                                        preferredStyle:UIAlertControllerStyleActionSheet];
alert.popoverPresentationController.sourceView = cell;
alert.popoverPresentationController.sourceRect = cell.bounds;
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
//...
[self presentViewController:alert animated:YES completion:nil];

#3


6  

You need to provide popoverPresentationController for iPad support. In this, you either specify barButtonItem or sourceView. This another thread may help you: Swift UIAlertController - ActionSheet iPad iOS8 Crashes

您需要为iPad提供popoverPresentationController支持。在这里,您可以指定barButtonItem或sourceView。另一个线程可以帮助您:Swift UIAlertController - ActionSheet ipadios8崩溃

#4


2  

Actually it is something buggy (I believe) in Xcode for iPhone and iPad designs for now.

实际上,我认为目前iPhone和iPad的Xcode设计存在缺陷。

  1. In iPhone same code works perfect and you can see the alert message at same position (always). But for iPad you need to define the alert box's position with alert.popoverPresentationController.sourceView = self.view; alert.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width / 2.0 - 105, self.view.bounds.size.height / 2.0 + 70, 1.0, 1.0); 105 and 70 are the approximate dimension differences for iPad portrait design due to different anchor point.
  2. 在iPhone中,同样的代码工作得非常完美,您可以在相同的位置(始终)看到警报消息。但是对于iPad,你需要用alert. popoverpresentationcontroller定义警报框的位置。sourceView = self。view;alert.popoverPresentationController。sourceRect = CGRectMake(self.view.bounds.size。宽度/ 2.0 - 105,self.view. bounds.com .size。身高/ 2.0 + 70,1.0,1.0);105和70是基于不同锚点的iPad肖像设计的近似尺寸差异。
  3. In iPhone design UIAlertController comes with 'Modal View' but unfortunately if you use same code for iPad it will not be a 'Modal View'. Which means that you need to write extra code for disabling touches in iPad design. I think it is weird.
  4. 在iPhone设计中,UIAlertController带有模态视图,但不幸的是,如果你在iPad上使用相同的代码,它就不是模态视图。这意味着你需要为iPad设计中禁用触摸编写额外的代码。我觉得这很奇怪。
  5. In iPad design you need to consider that anchor point is different. It is the bubble triangle point, not the upper left of AlertView.
  6. 在iPad设计中,你需要考虑锚点是不同的。它是气泡三角点,而不是AlertView的左上角。

These are the weird things I see. I think that there must be a standard and if someone wants to go out standards, fine, there can be other options.

这些是我看到的奇怪的东西。我认为必须有一个标准,如果有人想超越标准,好吧,还有其他的选择。

#5


1  

UIAlertController being iOS8 only, and needing to support iOS7, I am using it. I ran into this on a Master view in a Master/Detail layout on iPad. I was able to work around it (not exactly fix it) by raising the UIActionSheet from the parent UISplitViewController using [actionSheet showInView:]. Good luck.

UIAlertController仅为iOS8,需要支持iOS7,我正在使用它。我在iPad的Master/Detail布局中遇到过这个。我可以通过使用[actionSheet showInView:]从父UISplitViewController中提升UIActionSheet来解决它(不是完全修复它)。祝你好运。


推荐阅读
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • android 触屏处理流程,android触摸事件处理流程 ? FOOKWOOD「建议收藏」
    android触屏处理流程,android触摸事件处理流程?FOOKWOOD「建议收藏」最近在工作中,经常需要处理触摸事件,但是有时候会出现一些奇怪的bug,比如有时候会检测不到A ... [详细]
  •  项目地址https:github.comffmydreamWiCar界面做的很难看,美工方面实在不在行。重点是按钮触摸事件的处理,这里搬了RepeatListener项目代码,例 ... [详细]
  • 1.webkit内核中的一些私有的meta标签,这些meta标签在开发webapp时起到非常重要的作用(1) ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • 拥抱Android Design Support Library新变化(导航视图、悬浮ActionBar)
    转载请注明明桑AndroidAndroid5.0Loollipop作为Android最重要的版本之一,为我们带来了全新的界面风格和设计语言。看起来很受欢迎࿰ ... [详细]
  • Linux环境变量函数getenv、putenv、setenv和unsetenv详解
    本文详细解释了Linux中的环境变量函数getenv、putenv、setenv和unsetenv的用法和功能。通过使用这些函数,可以获取、设置和删除环境变量的值。同时给出了相应的函数原型、参数说明和返回值。通过示例代码演示了如何使用getenv函数获取环境变量的值,并打印出来。 ... [详细]
  • Html5-Canvas实现简易的抽奖转盘效果
    本文介绍了如何使用Html5和Canvas标签来实现简易的抽奖转盘效果,同时使用了jQueryRotate.js旋转插件。文章中给出了主要的html和css代码,并展示了实现的基本效果。 ... [详细]
  • C# WPF自定义按钮的方法
    本文介绍了在C# WPF中实现自定义按钮的方法,包括使用图片作为按钮背景、自定义鼠标进入效果、自定义按压效果和自定义禁用效果。通过创建CustomButton.cs类和ButtonStyles.xaml资源文件,设计按钮的Style并添加所需的依赖属性,可以实现自定义按钮的效果。示例代码在ButtonStyles.xaml中给出。 ... [详细]
  • Android开发实现的计时器功能示例
    本文分享了Android开发实现的计时器功能示例,包括效果图、布局和按钮的使用。通过使用Chronometer控件,可以实现计时器功能。该示例适用于Android平台,供开发者参考。 ... [详细]
  • FineReport平台数据分析图表显示部分系列接口的应用场景和实现思路
    本文介绍了FineReport平台数据分析图表显示部分系列接口的应用场景和实现思路。当图表系列较多时,用户希望可以自己设置哪些系列显示,哪些系列不显示。通过调用FR.Chart.WebUtils.getChart("chartID").getChartWithIndex(chartIndex).setSeriesVisible()接口,可以获取需要显示的系列图表对象,并在表单中显示这些系列。本文以决策报表为例,详细介绍了实现方法,并给出了示例。 ... [详细]
  • IOS开发之短信发送与拨打电话的方法详解
    本文详细介绍了在IOS开发中实现短信发送和拨打电话的两种方式,一种是使用系统底层发送,虽然无法自定义短信内容和返回原应用,但是简单方便;另一种是使用第三方框架发送,需要导入MessageUI头文件,并遵守MFMessageComposeViewControllerDelegate协议,可以实现自定义短信内容和返回原应用的功能。 ... [详细]
  • 涉及的知识点-ViewGroup的测量与布局-View的测量与布局-滑动冲突的处理-VelocityTracker滑动速率跟踪-Scroller实现弹性滑动-屏幕宽高的获取等实现步 ... [详细]
  • 篇首语:本文由编程笔记#小编为大家整理,主要介绍了10分钟了解Android的事件分发相关的知识,希望对你有一定的参考价值。什么是事件分发?大家 ... [详细]
author-avatar
于英豪H
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有