gpt4 book ai didi

ios8 - 旋转时未调用 UIView 子类的重写 traitCollectionDidChange() 方法

转载 作者:行者123 更新时间:2023-12-05 00:59:38 25 4
gpt4 key购买 nike

UITraitEnvironment 的文档说:

This method is called automatically when the current trait collection changes. Overriding this method provides you with a way to customize behavior when the trait collection associated with the view changes. If you do not override this method, no special behavior is performed.



但是当我旋转模拟器时,我的 UIView 子类中的这个重写方法没有被调用。

我的代码看起来像:
override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) { 
super.traitCollectionDidChange(previousTraitCollection)

println("______________________________")
}

我错过了什么吗?或者我对 API 文档的理解有误? thx 阐明它。

最佳答案

你在 iPad 上测试过吗?

可能是因为在 iPad 上,特征集合在纵向和横向上都是垂直和水平的常规。

试试这个方法应该可以的。
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator

关于ios8 - 旋转时未调用 UIView 子类的重写 traitCollectionDidChange() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27176030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com