iphone/ipad - 使用 Autoresize 和 addSubview 时出现问题
我几个小时以来一直在阅读 stackOverflow 对这个问题的回答。请帮我。
我正在使用 addSubview 显示视图。我的所有 UIView 对象都是通过 xib 文件加载的。层次结构是MainWindow.xib ->查看1.xib ->查看2.xib。每个都有一个控制器,它通过 initWithNibName:bundle: 加载 xibs。层次结构中的每个视图都在 IB 中选中了“自动调整子视图大小”属性。每个都还检查了其自动调整大小选项。 (又名红色小箭头。)
当单击 View1 上的按钮时,使用 addSubview 将 View2 作为子视图添加到 View1。这在 iPhone 上运行良好。
我现在正在让我的应用程序在 iPad 上运行。我的所有其他视图都工作正常并且调整大小正确。但 View2 没有。这是因为在调用调整大小函数之前它不会添加到 View1 中吗?如果是这样,如何触发自动调整大小功能?我缺少什么?
如果这还不够详细,我很抱歉。我也很乐意回答调试问题。经过两天的寻找,我还是感觉有些失落。
I have been reading stackOverflow answers for this question for hours. Please help me.
I am displaying a view using addSubview. All of my UIView objects are loaded via xib files. The hierarchy is MainWindow.xib -> View1.xib -> View2.xib. Each has a controller, which loads the xibs via initWithNibName: bundle:. Each View in the hierarchy has the Autoresize Subviews property checked in IB. Each one has their Autosizing options checked as well. (a.k.a. Little red arrows.)
View2 is added as a subview to View1, using addSubview, when a button on View1 is clicked. This works fine on the iPhone.
I am now making my app work w/ the iPad. All my other views work fine and resize correctly. But View2 does not. Is this because it doesn't get added to View1 until after it calls the resize functions? If so, how do I trigger the autoresize functionality? What am I missing?
I am sorry if this is not detailed enough. I'd be happy to respond to debugging questions as well. After two days of searching, I still simply feel a little lost.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将View2添加到View1的代码在哪里?你可能想做类似的事情
Where is the code that adds View2 to View1? You probably want to do something like