I thought I should supply a code sample to make my question more clear. I misspoke earlier, I'm showing the detail view from a UICollectionView. My detailVC just displays a piece of sheet music as a PDF.
Any help would be appreciated.
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let tuneID = self.dataSource.itemIdentifier(for: indexPath),
let tune = try? self.dataController.mainContext?.existingObject(with: tuneID) as? Tune
else { return }
collectionView.deselectItem(at: indexPath, animated: true)
guard let detailNC = TuneDetailVC.tuneDetailViewController(dataController: dataController),
let detailVC = detailNC.topViewController as? TuneDetailVC
else { return }
detailVC.tune = tune
splitViewController?.showDetailViewController(detailNC, sender: self)
if splitViewController?.displayMode == .twoBesideSecondary {
// Note: This should only occur in landscape on iPad.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak self] in
// Use 'hide' instead of settint 'preferredDisplayMode' for a smoother transition.
self?.splitViewController?.hide(.primary)
}
}
}
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: