Goal
I'm trying to add the peek and pop feature to my table row
Attempt
I added the extension
extension ProfileViewController : UIViewControllerPreviewingDelegate {
func detailViewController(for index: Int) -> ProfileDetailViewController {
guard let vc = storyboard?.instantiateViewController(withIdentifier: "profileDetail") as? ProfileDetailViewController else {
fatalError("Couldn't load detail view controller")
}
vc.selectedItem = index
vc.preferredContentSize = CGSize(width: 0.0, height: 300)
return vc
}
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
if let indexPath = profileTableView.indexPathForRow(at: location) {
previewingContext.sourceRect = profileTableView.rectForRow(at: indexPath)
return detailViewController(for: indexPath.row)
}
return nil
}
func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
navigationController?.pushViewController(viewControllerToCommit, animated: true)
}
}
I register it in my viewDidLoad()
override func viewDidLoad() { super.viewDidLoad()
registerForPreviewing(with: self, sourceView: profileTableView)
Result
When I run it, I can't seem to trigger the peek or pop ...
I kept going to my next page which my profile detail page.
Am I missing anything ?
In the console, I kept geting
The behavior of the UICollectionViewFlowLayout is not defined because:
the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
The relevant UICollectionViewFlowLayout instance is , and it is attached to ; layer = ; contentOffset: {272.5, -0.5}; contentSize: {1250, 217.80000000000001}; adjustedContentInset: {0.59999999999999432, 37.5, 0.59999999999999432, 37.5}> collection view layout: .
Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
Questions
How would one go about and debug this further ?
I'm open to any suggestions at this moment.
Any hints/suggestions / helps on this be will be much appreciated!
from How to implement Peek & Pop Feature of specific row of a table manually via code?
No comments:
Post a Comment