- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试模仿 Apple 默认应用程序“照片”中的导航逻辑。下面是应用导航逻辑的说明。
当您第一次启动该应用程序时,您会进入“ friend 圈” View ,该 View 位于该应用程序的第三高层级。这非常有趣,因为整个“照片”选项卡似乎都嵌入到单个 NavigationController 中。
但是,如果所有场景都嵌入到单个 NavigationController 中,您如何从非初始场景开始?
这是我的 hackish 实现,没有将场景嵌入到任何 NavigationController 中(所有 segues 都显示为 show
:
它会导致我想要的行为,但我不确定内存问题。我是否在每个循环中分配新的 VC?而且 Storyboard看起来不对。
作为答案,一个简单的 Storyboard 捕获和简短的解释会很好。
最佳答案
正如我在评论中所说,您需要修改 UINavigationController
的 .viewControllers
属性,您可以使用 setViewControllers(_:animated:)
方法或直接修改 .viewControllers
属性,其中 rootViewController
将是 viewControllersArray[0]
而 topViewController
将是 viewControllersArray[count-1]
此属性描述和详细信息可以在 UINavigationController
文档中找到
viewControllers
Property
The view controllers currently on the navigation stack.
声明SWIFT
var viewControllers: [UIViewController]
Discussion The root view controller is at index 0 in the array, the back view controller is at index n-2, and the top controller is at index n-1, where n is the number of items in the array.
Assigning a new array of view controllers to this property is equivalent to calling the setViewControllers:animated: method with the animated parameter set to false.
示例
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
let firstViewController = storyboard.instantiateViewController(withIdentifier: "FirstViewController") as? FirstViewController
let secondViewController = storyboard.instantiateViewController(withIdentifier: "SecondViewController") as? SecondViewController
let thirdViewController = storyboard.instantiateViewController(withIdentifier: "ThirdViewController") as? ThirdViewController
self.navigationController?.setViewControllers([firstViewController,secondViewController,thirdViewController], animated: false)
关于ios - 如何从非初始 NavigationController 场景开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46002976/
您好,所以我有这个 storyboard 结构 我在 ViewController B 中有一个 button 我需要那个 button 指向底部NavigationController 其中有 Vi
我的基于 Storyboard 的应用具有以下结构: NavigationController (NavCa) —> CollectionViewController (VCa) —> 模态呈现 —>
我可以用 MyFirstAppDelegate *delegate = (MyFirstAppDelegate *)[[UIApplication sharedApplication] delegat
我正在使用以下策略构建一个基于窗口的(所有 UI 都以编程方式连接,没有 IB)MonoTouch 应用程序: 伪代码: Note: I'm not calling base.ViewDidLoad
我发现了困难的方法 navigationController.navigationBarHidden = NO; 和 navigationController.navigationBar.hidden
这两种说法有什么区别。为了隐藏导航栏,我使用以下语句之一在 viewWillAppear 方法中隐藏导航栏,如下所示: -(void)viewWillAppear:(BOOL)animated {
我已经发布了这个问题,但这次我发布了代码。所以我有一个uiviewController,在这个viewController的viewDidLoad中我隐藏了navigationController的b
我想在横向显示另一个没有选项卡栏的 View 。所以我创建了一个新 View ,只更改 self.view 和 self.hidesBottomBarWhenPushed = YES; 但这对我不起作
当我将新的 ViewController 推送到导航 Controller 堆栈上时,“后退”按钮是前一个 Controller 的标题。 如何将后退按钮中的文本更改为“后退”而不是默认的最后一个 C
我在我的应用程序中设置了一个 subview “弹出窗口”,如果用户点击 subview 弹出窗口上的按钮,我想显示一个 navController。到目前为止,我已经设置了按钮,但是如果我点击按钮,
我有两个问题: 问题 1:我正在尝试更改导航后退按钮,我正在从父 ViewController 执行此操作: -(void)prepareForSegue:(UIStoryboardSegue *)s
我有一个 UINavigationController,它的根 Controller (UITableViewController) 和一个 UIViewController 的实例,当我单击导航 C
我正在尝试制作我的第一个基于表格的应用程序。但是它不会改变导航栏上标题的颜色。 我试过这段代码,但它似乎不起作用: this.NavigationController.NavigationItem.T
问题如图所示。我怎样才能从 viewcontroller C 返回到 A。方法 popViewController Animated 不起作用。 最佳答案 您的 Controller 层次结构存在问题
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit th
我在使用 Navigation Controller 转到我的详细 View 时遇到问题。 我正在使用 tableview 来显示一些练习,当你点击练习时,你会进入详细 View ,嵌入在导航 Con
我试图通过允许用户添加算命应用程序的新结果来理解演示 View Controller 。当用户点击导航栏右上角的“添加新结果”时,会弹出一个新的 View Controller ,用户可以在此处输入新
当我点击页面底部的灰色按钮时,我想使用 popToRootController 从最后一页返回到第一页。 我不明白如何同时对两个导航 Controller 进行操作。我为最后两页使用了一个库。 Sid
我有一个 navigationController 嵌入在我的 Root View 和 subview 中,并且在我的一个 subview 中有: @IBAction func button(send
是否可以将后退按钮的图标从箭头更改为其他图标? (在导航栏中) 我在storyboard的preferences里没找到解决方案 最佳答案 如果您的部署目标至少是 iOS 7,您可以使用 backIn
我是一名优秀的程序员,十分优秀!