UISplitViewControllerDetailViewController 子视图在方向更改时无法正确调整大小

发布于 2024-09-11 19:41:24 字数 728 浏览 2 评论 0原文

你好, 我的 iPad 应用程序中有以下设置:

UISplitViewController 详情侧-> SomeDetailViewController-> 添加子视图为 [SomeDetailViewController.view addSubview:AnotherViewController.view]

  1. 现在,启动后,当显示“AnotherViewController 视图”时,其初始尺寸始终与最后一个方向相同(界面生成器中的肖像/风景视图),我保存了该视图查看 XIB,无论当前设备方向如何。

  2. 另外,在重置添加的子视图(AnotherViewController.view)的框架时,即 A. 在 -[SomeDetailViewController viewDidLoad] 中检查当前设备方向 B. 设置 AnotherViewController.view 的框架以匹配所需的大小。此后,在方向更改时,它不会适当调整大小(我在 XIB 自动调整大小框中正确设置了弹簧/支柱)。

  3. ,我确实看到底部的 AnotherViewController.view 的大约一半不响应任何触摸,看起来由于框架的变化,响应坐标变得混乱。

  4. 我确实实现了“shouldAutorotateToInterfaceOrientation”,以便为我所有视图控制器中的所有方向返回“YES”。

    我确实实现了

TIA。

HI,
I have the following setup in my iPad application:

UISplitViewController
DetailSide->
SomeDetailViewController->
Added subview as [SomeDetailViewController.view addSubview:AnotherViewController.view]

  1. 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.

  2. 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.

  3. 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.

  4. I do have the "shouldAutorotateToInterfaceOrientation" implemented to return YES for all the orientation in all my view controllers.

TIA.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

筑梦 2024-09-18 19:41:25

您应该将 autoresize 属性设置为 AnotherViewController.view

AnotherViewController.view.view.autoresizingMask
= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

You should set autoresize properties to AnotherViewController.view:

AnotherViewController.view.view.autoresizingMask
= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

是你 2024-09-18 19:41:24

在 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];

    self.appDelegate.splitViewControllerObject.viewControllers = [NSArray arrayWithObjects:rootNav, detailNav, nil];
    self.appDelegate.splitViewControllerObject.delegate = detailviewobj;

    [UIAppDelegate.window addSubview:self.appDelegate.splitViewControllerObject.view];

祝你好运....

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];

    self.appDelegate.splitViewControllerObject.viewControllers = [NSArray arrayWithObjects:rootNav, detailNav, nil];
    self.appDelegate.splitViewControllerObject.delegate = detailviewobj;

    [UIAppDelegate.window addSubview:self.appDelegate.splitViewControllerObject.view];

good luck....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文