- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 UISplitViewController
,主 View 是UINavigationController
包含 UITableViewController
.有时,当用户选择表中的项目时,我不得不再推一次 UITableViewController
在主 View 中的现有表上。
在 iOS 7 中,我的第一个 UITableViewController
我只是打电话
[self.navigationController pushViewController:otherTableVC animated:YES];
UISplitViewController
的折叠模式干扰了我自己的导航 Controller ......
UINavigationController
在主 View 中?
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:otherTableVC];
[self.navigationController pushViewController:navController animated:YES];
最佳答案
简短的回答,您可以通过 UISplitViewControllerDelegate 方法控制此行为:
splitViewController:collapseSecondaryViewController:ontoPrimaryViewController:
splitViewController:separateSecondaryViewControllerFromPrimaryViewController:
#pragma mark -
#pragma mark Split View Controller delegate.
- (BOOL)splitViewController:(UISplitViewController *)splitViewController showViewController:(UIViewController *)vc sender:(id)sender
{
//Standard behaviour. This won't get called in our case when the split view is collapsed and the primary view controllers are obscured.
return NO;
}
// Since we treat warnings as errors, silence warning about unknown selector below on UIViewController subclasses.
#pragma GCC diagnostic ignored "-Wundeclared-selector"
- (BOOL)splitViewController:(UISplitViewController *)splitViewController showDetailViewController:(UIViewController *)vc sender:(id)sender
{
if (splitViewController.collapsed == NO)
{
// The navigation controller we'll be adding the view controller vc to.
UINavigationController *navController = splitViewController.viewControllers[1];
UIViewController *topDetailViewController = [navController.viewControllers lastObject];
if ([topDetailViewController isKindOfClass:[BlankViewController class]] ||
([vc respondsToSelector:@selector(shouldReplaceDetailedView)] && [vc performSelector:@selector(shouldReplaceDetailedView)]))
{
// Replace the (expanded) detail view with this new view controller.
[navController setViewControllers:@[vc] animated:NO];
}
else
{
// Otherwise, just push.
[navController pushViewController:vc animated:YES];
}
}
else
{
// Collapsed. Just push onto the conbined primary and detailed navigation controller.
UINavigationController *navController = splitViewController.viewControllers[0];
[navController pushViewController:vc animated:YES];
}
// We've handled this ourselves.
return YES;
}
- (BOOL)splitViewController:(UISplitViewController *)splitViewController collapseSecondaryViewController:(UIViewController *)secondaryViewController ontoPrimaryViewController:(UIViewController *)primaryViewController
{
UINavigationController *primaryNavController = (UINavigationController *)primaryViewController;
UINavigationController *secondaryNavController = (UINavigationController *)secondaryViewController;
UIViewController *bottomSecondaryView = [secondaryNavController.viewControllers firstObject];
if ([bottomSecondaryView isKindOfClass:[BlankViewController class]])
{
NSAssert([secondaryNavController.viewControllers count] == 1, @"BlankViewController is not only detail view controller");
// If our secondary controller is blank, do the collapse ourself by doing nothing.
return YES;
}
// We need to shift these view controllers ourselves.
// This should be the primary views and then the detailed views on top.
// Otherwise the UISplitViewController does wacky things like embedding a UINavigationController inside another UINavigation Controller, which causes problems for us later.
NSMutableArray *newPrimaryViewControllers = [NSMutableArray arrayWithArray:primaryNavController.viewControllers];
[newPrimaryViewControllers addObjectsFromArray:secondaryNavController.viewControllers];
primaryNavController.viewControllers = newPrimaryViewControllers;
return YES;
}
- (UIViewController *)splitViewController:(UISplitViewController *)splitViewController separateSecondaryViewControllerFromPrimaryViewController:(UIViewController *)primaryViewController
{
UINavigationController *primaryNavController = (UINavigationController *)primaryViewController;
// Split up the combined primary and detail navigation controller in their component primary and detail view controller lists, but with same ordering.
NSMutableArray *newPrimaryViewControllers = [NSMutableArray array];
NSMutableArray *newDetailViewControllers = [NSMutableArray array];
for (UIViewController *controller in primaryNavController.viewControllers)
{
if ([controller respondsToSelector:@selector(shouldDisplayInDetailedView)] && [controller performSelector:@selector(shouldDisplayInDetailedView)])
{
[newDetailViewControllers addObject:controller];
}
else
{
[newPrimaryViewControllers addObject:controller];
}
}
if (newDetailViewControllers.count == 0)
{
// If there's no detailed views on the top of the navigation stack, return a blank view (in navigation controller) for detailed side.
UINavigationController *blankDetailNavController = [[UINavigationController alloc] initWithRootViewController:[[BlankViewController alloc] init]];
return blankDetailNavController;
}
// Set the new primary views.
primaryNavController.viewControllers = newPrimaryViewControllers;
// Return the new detail navigation controller and views.
UINavigationController *detailNavController = [[UINavigationController alloc] init];
detailNavController.viewControllers = newDetailViewControllers;
return detailNavController;
}
关于uinavigationcontroller - 在 iOS 8 中 UISplitViewController 的主视图中有一个 UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26060915/
我有一个基于 REST 的经典 springboot 应用程序。我想开始使用 Vaadin,以便直接从 java 代码创建 ui 组件。 我在他们的教程中发现,您必须使用 @Route('') 创建一
为了设计,我使用 Storyboard。主页 View Controller 包含单独 View 中的侧面菜单,我设计了带有 Collection View 的主页。对于侧面菜单,我使用包含 MyNa
我正在寻找如何为 UWP Win 10 应用程序构建主/详细 View 的好示例,如本页所示:https://msdn.microsoft.com/en-us/library/windows/apps
我遇到这个问题,在 iPhone 7 Plus 的横向模式下,当单击设备左侧表格 View 中的单元格时,内容会显示在表格 View 的顶部,或者替换表格 View .在这种情况下, Split Vi
我想改变我的主视图(不是按钮或 TextView )的背景颜色,只是通常是黑色的真实背景......我得到了这个代码: view.setBackgroundColor(0xfff00000); 这在
我正在尝试在 Android 应用程序中使用 Wikitude API,但相关文档很少。 那么,有什么办法可以在wikitude View 中添加一个action bar吗?还有一些按钮?因为我只看到
我正在尝试隐藏 navigationViewControleler 层次结构的桅杆 View Controller 中的工具栏。 我创建一个新的 ViewController 作为 RootViewC
已关闭。此问题不符合Stack Overflow guidelines .它目前不接受答案。 要求提供代码的问题必须表现出对所解决问题的最低限度理解。包括尝试过的解决方案、为什么它们不起作用,以及
我正在寻找实现可编辑详细 View 的可能性。我的应用程序有一个经典的主 -> 详细 View 设置。苹果文档(http://developer.apple.com/library/ios/#feat
我正在使用一个框架,该框架使用其特定控件创建 UIViewControllers。我无法访问其 Storyboard来手动修改它。有没有办法向其 View 添加标签之类的内容并正确定位它,即使 Vie
我有带 subview 和应用约束的 View Controller 。 问题:我想做的是以编程方式添加 ScrollView 只有 iPhone 4s 设备在 ScrollView 中具有 self
我有基本的主视图/详细 View 与默认的 ASP.NET MVC 路由配合得很好;但是我想构建一些这样的 URL: /Class/Details/5 -- General Detail view [
我需要在 Split View Controller 中更改 View Controllers 的宽度大小。我的意思是第一个 View Controller 的默认值是 320。第二个是 703。我需
我是一名优秀的程序员,十分优秀!