gpt4 book ai didi

ios - UISplitViewController 未正确旋转

转载 作者:行者123 更新时间:2023-11-29 04:46:13 25 4
gpt4 key购买 nike

我知道有关堆栈溢出的主题有很多讨论,但没有一个问题有适合我的答案。

我有一个作为 Root View Controller 加载的 SplitViewController,并且 SVC 内的两个 TableView 都将 ShouldAutoRotate 设置为返回 YES。

即使时钟/状态栏可以,SVC 也不会随 iPad 正确旋转。

<小时/> 更新

在我的 AppDelegate 中,我注意到 rootViewController 在我设置之后才真正被设置 - rootViewController 不应该总是被设置吗?这段代码:

    MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"RootViewController pre set: %@", appDelegate.window.rootViewController);
[appDelegate.window setRootViewController:splitViewController];
NSLog(@"RootViewController post set: %@", appDelegate.window.rootViewController);

记录为:

RootViewController pre set: (null)
RootViewController post set: <UISplitViewController: 0x88ad2d0>

这是否意味着我错误地认为 SVC 是 Root View Controller ?

此外,在 IB 中 - 窗口没有任何东西连接到 rootViewController 导出 - 这是一个问题吗?


这是以编程方式创建 SVC 的位置:

-(IBAction)makeStory:(id)sender{
MakeSentenceTableViewController *detailViewController = [[MakeSentenceTableViewController alloc] initWithNibName:@"MakeSentenceTableViewController" bundle:nil];

UISplitViewController *splitViewController = [[[UISplitViewController alloc] init] autorelease];

UINavigationController *rootNav = [[[UINavigationController alloc] initWithRootViewController:makeStoryTableViewController]autorelease];

UINavigationController *detailNav = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];

splitViewController.viewControllers = [NSArray arrayWithObjects:rootNav, detailNav, nil];
splitViewController.delegate = makeStoryTableViewController;

MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.window setRootViewController:splitViewController];
}

这是两个 TableView 中的 ShouldAutoRotate 部分(它们在两个 TableView 中都是相同的):

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSLog(@"story idiom for rotate is iPad");
return YES;
}

请帮助我解决这个问题,以便 SplitViewController 正确加载 - 或者帮助我使用一些调试技术(例如,我如何检查以确保 SVC 位于 rootViewController 中,是否有其他方法来调试旋转麻烦?) 。

最佳答案

啊。通常,提问过程的一部分会导致你自己回答。

我必须将 IB 中 MainWindow~ipad.xib 的 rootViewController 导出连接到 AppDelegate 中的 viewController,然后一切就开始工作了。

所以我没有正确地将 UISplitViewController 设置为 rootViewController。

关于ios - UISplitViewController 未正确旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9612036/

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