UISplitview 未在顶部对齐

发布于 2024-12-02 06:39:37 字数 1417 浏览 2 评论 0原文

我有一个无法弄清楚的问题,我制作了一个在选项卡栏中使用 UIsplitview 的应用程序。我一直在实现不同的选项卡,但是现在当我在第一个选项卡上工作时 - UIsplitview 在横向模式下未对齐。你们有什么建议吗?如果我以纵向模式开始,然后转到横向模式,那就完全没有问题了。

在此处输入图像描述

更新: 我不会在任何地方对框架进行任何初始化,并且我已经在 IB 中检查了尺寸等。下面显示了我如何在应用程序委托中添加 uisplitview 控制器。这样做是因为我想在标签栏控制器中使用分割视图。当我添加 spilview 时,我只是在 IB 中设置了主视图和详细视图。有点神秘。

if (index == 2) {

        detailViewController = [[DetailUserCreatorViewController alloc] initWithNibName:@"DetailUserCreatorView" bundle:nil];

        userContent=[[UserContentForPopViewController alloc]init];

        userContent.userDetails=detailViewController;

        detailViewController.delegate=userContent;

        //rootViewController.navigationItem.title = @"List";
        UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:userContent] autorelease];

        splitViewController = [[UISplitViewController alloc] init];
        splitViewController.tabBarItem = controller.tabBarItem;
        splitViewController.viewControllers = [NSArray arrayWithObjects:nav, detailViewController, nil];

        splitViewController.delegate = detailViewController;

        [controllers replaceObjectAtIndex:index withObject:splitViewController];
    }

更新:我尝试在应用程序委托中的应用程序 didfinishlaunch 中设置选定的选项卡 - self.tabBarController.selectedIndex = 0;这使得选项卡在正确的位置开始。然而,这似乎不是一个正确的解决方案。

I have a problem I can't figure out, I have made an application which uses UIsplitview inside a tab bar. I have been implementing the different tabs however now when I am working on the first tab - the UIsplitview is not aligned in landscape mode. Do you guys have any suggestions - if I start it in portrait and go to landscape, then there's no problem at all.

enter image description here

Update:
I dont do any init with frames anywhere, and I have checked the sizes etc. in IB. The following shows how I add the uisplitview controller in the app delegate. It has been done this way because I wanted a splitview in a tabbar controller. When i have added the spilview I just set the master and detail view in IB. A bit of mystery.

if (index == 2) {

        detailViewController = [[DetailUserCreatorViewController alloc] initWithNibName:@"DetailUserCreatorView" bundle:nil];

        userContent=[[UserContentForPopViewController alloc]init];

        userContent.userDetails=detailViewController;

        detailViewController.delegate=userContent;

        //rootViewController.navigationItem.title = @"List";
        UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:userContent] autorelease];

        splitViewController = [[UISplitViewController alloc] init];
        splitViewController.tabBarItem = controller.tabBarItem;
        splitViewController.viewControllers = [NSArray arrayWithObjects:nav, detailViewController, nil];

        splitViewController.delegate = detailViewController;

        [controllers replaceObjectAtIndex:index withObject:splitViewController];
    }

Update: I tried to set the selected tab in application didfinishlaunch in the app delegate - self.tabBarController.selectedIndex = 0; and this made the tab start at the correct placement. However it does not seem to be a proper solution.

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

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

发布评论

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

评论(1

我的黑色迷你裙 2024-12-09 06:39:37

一些指针... splitViewController 需要添加为窗口的子视图:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

[window addSubview:splitViewController.view];
[window makeKeyAndVisible];

return YES;
}

以下代码不正确。您不应该将 viewController 分配给委托。

splitViewController.delegate = detailViewController;

您也不需要这行代码:

[controllers replaceObjectAtIndex:index withObject:splitViewController];

以下行处理分配委托的部分。

splitViewController.viewControllers = [NSArray arrayWithObjects:nav, detailViewController, nil];

另外,如果您可以上传代码,我会尝试更正它并发回原因和更正的代码...

Some pointers...splitViewController needs to be added as a subview of window:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

[window addSubview:splitViewController.view];
[window makeKeyAndVisible];

return YES;
}

The following code is incorrect. You should not assign a viewController to a delegate.

splitViewController.delegate = detailViewController;

You will also not require this line of code:

[controllers replaceObjectAtIndex:index withObject:splitViewController];

The following line handles that part of assigning delegates.

splitViewController.viewControllers = [NSArray arrayWithObjects:nav, detailViewController, nil];

Also, if you can upload your code, I'll try to correct it and post back the reason and corrected code...

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