
从iOS 6开始,事情似乎发生了很大变化.
当我在vIEwDIDLoad中的视图上调用setFrame时,没有任何效果.我从vIEwWillAppear中尝试过一样.
setFrame调用将在willAnimateRotationToInterfaceOrIEntation中工作,但最初不像iOS 5中那样调用.
有人可以澄清一下我预期的布局方式吗?
解决方法 我想你想从UIVIEwController布局您的视图.您是否尝试在 viewDidLayoutSubviews执行布局任务:- (voID)vIEwDIDLayoutSubvIEws
根据苹果的文档:
Your vIEw controller can overrIDe this method to make changes after the vIEw lays out its subvIEws.
由于您的视图本身不会对其子视图进行布局(您不使用autosize,autolayout或layoutSubVIEws :)可以在此方法中执行布局任务.
然而,优雅的方式是使用自定义父UIVIEw并执行所有布局,覆盖UIVIEw的layoutSubVIEws:(除非您双方添加/删除视图).苹果公司@L_301_1@的文档报道:
总结IDeally,the vIEws themselves perform all of the necessary work to reposition themselves,without requiring the vIEw controller to participate in the process at all. However,if the vIEw controller adds and removes vIEws dynamically,a static layout in Interface Builder may not be possible. In this case,the vIEw controller is a good place to control the process,because often the vIEws themselves only have a limited picture of the other vIEws in the scene.
以上是内存溢出为你收集整理的iOS:setFrame不再从viewDidLoad或viewWillAppear工作全部内容,希望文章能够帮你解决iOS:setFrame不再从viewDidLoad或viewWillAppear工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)