如何仅在 SplitView 中的横向模式下隐藏 rootView 控制器
现在我有代码允许我隐藏代表 rootView 控制器的侧栏。当我进入横向模式时,“根列表”按钮被“隐藏侧边栏”按钮替换,单击时它会从 splitView 中删除 RootViewController。以下是在 AppDelegate 中找到的代码:
//Thanks to Alice McGregor for the code!!!
- (IBAction)toggleSplitView:(id)sender {
if ( [window.subviews containsObject:splitViewController.view] ) {
[splitViewController.view removeFromSuperview];
splitViewController.viewControllers = [NSArray arrayWithObjects: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"];
}
}
当选择隐藏侧边栏按钮时,这将删除 rootView(表)。但是,当您切换到纵向模式时,根列表按钮不存在,而是被“显示侧边栏”按钮取代。
我需要这样做,以便在横向模式下隐藏表格,但您仍然可以在纵向模式下选择根列表按钮。有什么想法吗?
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 arrayWithObjects: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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论