开发者

How to hide the rootView controller only in landscape mode in a SplitView

Right now I have code that allows me to hide the side bar which represents the rootView Controller. When I go into landscape mode the "root list" button is replaced by a "hide sidebar" button and when clicked it removes the RootViewController from the splitView. Here is the code found in the AppDelegate:

//Thanks to Alice McGregor for the code!!!
- (IBAction)toggleSplitView:(id)sender {
    if ( [window.subviews containsObject:splitViewController.view] ) {

        [splitViewController.view removeFromSuperview];

        splitViewController.viewControllers = [NSArray arrayWithOb开发者_StackOverflow中文版jects:rootViewController, rootViewController, nil];

        [window addSubview:detailViewController.view];

        [(UIBarButtonItem *)sender setTitle:@"Show Sidebar"];

    } else {

        [detailViewController.view removeFromSuperview];
        [detailViewController.view setTransform:CGAffineTransformIdentity];

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

        [window addSubview:splitViewController.view];
        [detailViewController.view sizeToFit];

        [(UIBarButtonItem *)sender setTitle:@"Hide Sidebar"];
    }
}

This removes the rootView (table) when the hide sidebar button is selected. However, when you flip to portrait mode, the root list button isn't there and is instead replaced by the "show sidebar" button.

I need to make this so that when in landscape mode, the table is hidden, however you can still select the root list button in portrait mode. Any ideas?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜