我将使用导航控制器从一个视图推到另一个视图,但我没有弹出任何我推送的视图。因此,当我加载一个视图时,我想要从堆栈中弹出前一个视图。
推送视图的代码:
推送视图的代码:
var identities = [String]()
identities = ["A", "B", "C", "D", "E"]
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let vcName = identities[indexPath.row]
let viewController = storyboard?.instantiateViewController(withIdentifier: vcName)
self.navigationController?.pushViewController(viewController!, animated: true)
}
弹出视图的测试代码(不过这不是我想要的):
self.navigationController?.viewControllers.remove(at: 0)
非常感谢您的帮助。
已解决:
@DonMag帮助我了解了代码行的正确使用和放置位置。