gpt4 book ai didi

objective-c - 从横向 View Controller 推送纵向 View Controller

转载 作者:行者123 更新时间:2023-12-01 17:01:42 24 4
gpt4 key购买 nike

我有一个 UITableViewController 可以在纵向和横向上工作。从这个 Controller ,我将另一个 View Controller 推到导航 Controller 上。这个新的 viewController 只是纵向的。

问题是,当我处于横向并插入 View Controller 时,新的 View Controller 也处于横向状态,直到我将其旋转为纵向。然后它被卡在肖像中,因为它应该是。

是否有可能总是让它出现在肖像中?即使它的 parent 在横向插入它?

更新:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

最佳答案

在 viewWillAppear: 状态栏方向改变后放这个:

//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];

希望它会有所帮助!

P.S.在 sdk 3.2.5 ios 5.0.1 上测试。

关于objective-c - 从横向 View Controller 推送纵向 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6192141/

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