【发布时间】:2018-03-21 01:37:13
【问题描述】:
左下角的控制器是AddPhotoVC
在 SelectAlbumVC 中我有这个代码:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let destination = segue.destination as? AddPhotoPostVC
else { fatalError("unexpected view controller for segue") }
guard let cell = sender as? AlbumListCells else { fatalError("unexpected cell for segue") }
switch SegueIdentifier(rawValue: segue.identifier!)! {
case .showAllPhotos:
destination.fetchResult = allPhotos
destination.headerTitleBtnString = cell.allPhotoTitle.text!
case .showCollection:
// get the asset collection for the selected row
let indexPath = tableView.indexPath(for: cell)!
let collection: PHCollection
switch Section(rawValue: indexPath.section)! {
case .smartAlbums:
collection = smartAlbums.object(at: indexPath.row)
case .userCollections:
collection = userCollections.object(at: indexPath.row)
default: return // not reached; all photos section already handled by other segue
}
// configure the view controller with the asset collection
guard let assetCollection = collection as? PHAssetCollection
else { fatalError("expected asset collection") }
destination.fetchResult = PHAsset.fetchAssets(in: assetCollection, options: nil)
destination.assetCollection = assetCollection
destination.headerTitleBtnString = cell.collectionTitle.text!
destination.isComingFromSelectAlbum = true
}
}
所以基本上当我单击一个单元格时,segue 将被执行并将数据传递给 AddPhotoVC。 我的问题是,当执行 segue 时,与 SelectAlbumVC 关联的导航控制器不会被解除,因此当单击 AddPhotoVC 上的解除按钮时 SelectAlbumVC 会再次出现(它是堆栈中的最后一个控制器)。
有没有办法在调用 prepare for segue 时关闭导航控制器? 我已经尝试添加底部
self.navigationController?.popToRootViewController(animated: false)
但它不起作用。
任何帮助将不胜感激。
谢谢!
【问题讨论】:
标签: ios swift uiviewcontroller uinavigationcontroller uistoryboardsegue