UISplitViewControllerDetailViewController 子视图在方向更改时无法正确调整大小
你好, 我的 iPad 应用程序中有以下设置:
UISplitViewController 详情侧-> SomeDetailViewController-> 添加子视图为 [SomeDetailViewController.view addSubview:AnotherViewController.view]
现在,启动后,当显示“AnotherViewController 视图”时,其初始尺寸始终与最后一个方向相同(界面生成器中的肖像/风景视图),我保存了该视图查看 XIB,无论当前设备方向如何。
另外,在重置添加的子视图(AnotherViewController.view)的框架时,即 A. 在 -[SomeDetailViewController viewDidLoad] 中检查当前设备方向 B. 设置 AnotherViewController.view 的框架以匹配所需的大小。此后,在方向更改时,它不会适当调整大小(我在 XIB 自动调整大小框中正确设置了弹簧/支柱)。
- ,我确实看到底部的 AnotherViewController.view 的大约一半不响应任何触摸,看起来由于框架的变化,响应坐标变得混乱。
我确实实现了“shouldAutorotateToInterfaceOrientation”,以便为我所有视图控制器中的所有方向返回“YES”。
我确实实现了
TIA。
HI,
I have the following setup in my iPad application:
UISplitViewController
DetailSide->
SomeDetailViewController->
Added subview as [SomeDetailViewController.view addSubview:AnotherViewController.view]
Now after launching when the "AnotherViewController view" is displayed, its initial dimensions are always same of the last orientation(potrait/landscape view in interface builder) I saved that view XIB with, irrespective of the current device orientation.
Also On resetting the frame of the added subview(AnotherViewController.view) i.e A. In -[SomeDetailViewController viewDidLoad] check for the current device orientation B. Set the frame of the AnotherViewController.view to match the required size. It doesnt resize appropriately thereafter(I have the springs/struts setup correctly in XIB autoresizing box) on orientation changes.
After doing step 2. above, I do see that around half of the AnotherViewController.view from bottom doesnt respond to any touches, looks like due to change in frame the responding co-ordinates get messed up.
I do have the "shouldAutorotateToInterfaceOrientation" implemented to return YES for all the orientation in all my view controllers.
TIA.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该将 autoresize 属性设置为
AnotherViewController.view
:You should set autoresize properties to
AnotherViewController.view
:在 XIB 中,将有一个选项可以更改 Inspector 中的 SPlitview Detail/Master。此外,如果将其添加为子视图,则无法获取 splitview 委托方法,因为您需要将其添加到 window. 从窗口中删除所有元素
尝试使用[[[[UIAppDelegate window ] subviews] objectAtIndex:0] removeFromSuperview] ;
self.appDelegate.splitViewControllerObject = [[UISplitViewController alloc] init];
UINavigationController *rootNav = [[UINavigationController alloc]initWithRootViewController:masterview];
UINavigationController *detailNav = [[UINavigationController alloc]initWithRootViewController:detailview];
祝你好运....
In XIB there will be an option to change the SPlitview Detail/Master in Inspector. Also if you add it as a subview you cannot get the splitview delegate methods, for that you will need to add it to window. Try removing all the elements from window using
[[[[UIAppDelegate window ] subviews] objectAtIndex:0] removeFromSuperview];
self.appDelegate.splitViewControllerObject = [[UISplitViewController alloc] init];
UINavigationController *rootNav = [[UINavigationController alloc]initWithRootViewController:masterview];
UINavigationController *detailNav = [[UINavigationController alloc]initWithRootViewController:detailview];
good luck....