开发者

positioning problem with uisplitviewcontroller in left view

开发者 https://www.devze.com 2023-01-30 06:52 出处:网络
i got a little problem, when launching my splitview in landscape, there is a little black space above my left view controller:

i got a little problem, when launching my splitview in landscape, there is a little black space above my left view controller:

positioning problem with uisplitviewcontroller in left view

after rotating my ipad to portrait and switching back to landscape, the space is gone.

if i load the uitableviewcontroller directly into the left view, and not in a navigationcontroller, it works fine:

positioning problem with uisplitviewcontroller in left view

any ideas why this is happening ??

// Produkte
    self.produkteMainTableVC = [[produkteMainTableViewController alloc] initWithStyle:UITableViewStylePlain];
    UINavigationController *produkteMainNavigationController = [[UINavigationController alloc] initWithRootViewController:self.produkteMainTableVC];
    self.produkteDetailVC = [[produkteDetailViewController alloc] initWithNibName:@"produkteDetailViewController" bundle:nil];
    self.produkteSplitVC = [[UISplitViewController alloc] init];

    self.produkteSplitVC.delegate = self.produkteDetailVC;
    self.produkteMainTableVC.produkteDetailVC = produkteDetailVC;
    [self.produkteSplitVC setViewControllers:[NSArray arrayWithObjects:produkteMainNavigationController,self.produkteDetailVC,nil]];

thanks for all help!

edit: its exactly 20px like the statusbar. does that help anyone?

edit2:

doing something like this:

if(self.navigationController.navigationBar.frame.origin.y >= 20.0) {

        self.navigationController.navigationBar.frame = CGRectMake(self.navigationController.navigationBar.frame.origin.x, 0.0, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height);
    }

results that:

positioning problem with uisplitviewcontroller in left view

a little improvement i would say. b开发者_StackOverflow中文版ut i have no idea how to stick my tableview underneath the navigationbar.


I know this is a very old topic but maybe it'll help other people...

I had the same issue (with the same configuration : splitview in tabbar). This property solved it !

[self.splitViewController setWantsFullScreenLayout:YES];


UINavigationController has a nasty habit of shifting its contents down by 20px, depending where you place it. I'm guessing it's doing it here because your split view controller is inside of a tabbar controller, and Apple has not blessed this type of arrangement.


I've run into this same issue, with out a resolution. The only thing I've noticed is this does NOT happen when the master does not include a UINavigationController as its root.

Anyone figure a solution to this?


Here's what I did, and it seems to work fine.

I created my own custom tab-view controller, derived from UIViewController. In viewDidLoad I add a UITabBar to the bottom of the view and set the delegate to myself so I can handle tab changes. (I return this UITabBar as the rotatingFooterView) Tab changes result in swapping the current view controller, just like a real UITabBarController. When swapping view controllers (sometimes a UISplitViewController, hosting a UINavigationController in the master view), I add and position the view-controller's view within my view, above the UITabBar. I'm also careful to forward viewWill/DidAppear/Disappear calls to the current view controller, as well as each of the will/didRotate messages.


seems that this problem occurs from iOS 7.0. Setting the frame of UINavigationBar in some cases doesn't work. I think this can solve your problem :

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        self.navigationController.view.frame = CGRectMake(0, -20, self.navigationController.view.frame.size.width,
                                                          self.navigationController.view.frame.size.height);
    }

This code should be called only once (for example in - (void)viewDidLoad ). In my case it works for all device orientation.

0

精彩评论

暂无评论...
验证码 换一张
取 消