ios - UINavigationController 方法将 View Controller 添加到导航堆栈?

标签 ios swift xcode

UINavigationController 的哪个方法用于在 swift 中将 View Controller 添加到导航堆栈?

最佳答案

通常使用下面的方法将UIViewController推送到UINavigationController的导航栈

pushViewController(_ viewController: UIViewController, animated: Bool)

这是在您的 CustomViewController 类中以下列方式实现的:

let someVC: CustomViewController = CustomViewController() // this is one way of initializing it
self.navigationController?.pushViewController(someVC, animated: true)

以下是另一种方法,可用于将 UIViewController 添加到 UINavigationController 堆栈

setViewControllers(_ viewControllers: [UIViewController], animated: Bool)

关于ios - UINavigationController 方法将 View Controller 添加到导航堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40562566/

相关文章:

ios - Swift: 'NSArray?' 无法转换为 'NSArray?'

ios - 如何更改 UINavigationItem 字体?

xcode - 将所有 Xcode 设置恢复到原始状态

ios - 将 UIView 添加到 UITableView 的标题而不是部分的标题

ios - UITableViewCell 中的 UIButton(在 UIView 内)单击事件不起作用

ios - swift : Get tableView indextPath/textLabel from selected UIView

ios - 找不到 GStreamer Xcode 10 gst.h

xcode - 如何从终端命令引用当前目录

iOS SwiftUI 视频自动播放

ios - React Native v0.61.5 获取 ITMS-90809 : Depracated API Usage