iOS 8上的弹出窗口中的UIDatePicker问题 [英] UIDatePicker issues in popovers on iOS 8

查看:132
本文介绍了iOS 8上的弹出窗口中的UIDatePicker问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有其他人在iOS 8的popovers中遇到UIDatePickers问题?突然我们的日期选择器没有正确显示(见截图)。似乎没有显示部分选择器(但是,您仍然可以与缺失的部分进行交互以更改时间)。

Is anyone else having issues with UIDatePickers in popovers on iOS 8? Suddenly our date pickers are not showing up correctly (see screenshot). It appears that part of the picker is not being displayed (though, you can still interact with the missing portion to change the time).

我做了一些测试和日期拾取器在其他视图中完美显示,因此它与弹出窗口相关或在不是全屏的视图中显示拾取器。

I did some testing, and date pickers display perfectly in other views, so it's something related to either popovers or displaying the pickers in a view that is not full screen.

是否有人找到修复或解决方法对于这些问题?

Has anyone found a fix or a workaround for these issues?

推荐答案

我在Apple Developer论坛中找到了一个解决方案(当Stack Overflow让我失望时,我的备份知识库)。

I found a solution in the Apple Developer Forums (my backup knowledge base when Stack Overflow fails me).

用户Natsu有以下解决方案:

User Natsu had the following solution:


我的项目遇到同样的问题。它只会导致iPad
设备(iPhone使用相同的代码没有问题)。据我所知,
UIDatePicker包含UITableView和UITableViewCell,用于显示
选取器内容,其背景颜色默认设置为白色。这个
就是这个问题的原因。 iOS 7在UIDatePicker中有UITableViewCell和白色
背景iOS 8在UIDatePicker中有UITableView和白色背景
所以我的解决方案是我通过使用UIAppearance将这些背景颜色
设置为nil:

I have the same problem in my project. And it causes only on iPad devices (iPhone has no problem with same code). As my understanding, UIDatePicker contains UITableView and UITableViewCell for displaying picker contents and its background color is set white as default. This is the reason of this issue. iOS 7 has UITableViewCell with white background in UIDatePicker iOS 8 has UITableView with white background in UIDatePicker So my solution is that I set these background color to nil by using UIAppearance like this:



[[UITableView appearanceWhenContainedIn:[UIDatePicker class], nil] setBackgroundColor:nil]; // for iOS 8
[[UITableViewCell appearanceWhenContainedIn:[UIDatePicker class], [UITableView class], nil] setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.0]]; // for iOS 7




我设置的值是
iPhone上使用的颜色。我不确定这是解决
问题的正确方法。但至少在我的环境中它运作良好。我不知道UIPickerView的问题是否因为同样的原因而导致
。但是
检查视图层次结构可能对你有所帮助。

The values I set are the color used on iPhone. I'm not sure that it's a correct way to fix the issue. But at least in my environment it works well. I don't know if the problem of UIPickerView causes by same reason. But checking view hierarchy may help you.

由于这使用UIAppearance,你几乎可以把它放在任何地方。我把它放在我的表格单元类中的awakeFromNib中,它就像一个魅力。谢谢Natsu!

Since this uses UIAppearance you can put it almost anywhere. I put it in awakeFromNib in my table cell class and it worked like a charm. Thanks Natsu!

这篇关于iOS 8上的弹出窗口中的UIDatePicker问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆