0
UITableView
は1つのViewControllerに2つあり、UIView
があります.PeekとPopを実装しようとしていますが、両方のテーブルを登録するたびに、 。上記1つのUIViewControllerで複数のUITableViewにピークとポップを実装
if tableView.point(inside: tableViewPoint, with: nil) {
guard let indexPath = self.tableView.indexPathForRow(at: location) else { return nil }
guard let cell = self.tableView.cellForRow(at: indexPath) else { return nil }
let storyBoard = UIStoryboard(name: "Home", bundle: nil)
guard let previewViewController = storyBoard.instantiateViewController(withIdentifier: "article_page") as? ArticleViewController else { return nil }
previewViewController.preferredContentSize = CGSize(width: 0.0, height: 550)
previewViewController.passedValue = article_ids[(indexPath as NSIndexPath).row]
previewingContext.sourceRect = cell.frame
return previewViewController
} else {
guard let indexPath = self.tableView2.indexPathForRow(at: location) else { return nil }
guard let cell = self.tableView2.cellForRow(at: indexPath) else { return nil }
let storyBoard = UIStoryboard(name: "Home", bundle: nil)
guard let previewViewController = storyBoard.instantiateViewController(withIdentifier: "article_page") as? ArticleViewController else { return nil }
previewViewController.preferredContentSize = CGSize(width: 0.0, height: 550)
if indexPath.row == 0 {
previewViewController.passedValue = 1001
} else {
previewViewController.passedValue = weekly_article_id_[(indexPath as NSIndexPath).row - 1]
}
previewingContext.sourceRect = cell.frame
return previewViewController
}
動作しません:
if traitCollection.forceTouchCapability == UIForceTouchCapability.available {
registerForPreviewing(with: self, sourceView: self.tableView2)
registerForPreviewing(with: self, sourceView: self.tableView)
}
マイviewControllerForLocation
:以下は、私がUITableViews
を登録しています場所です。 (おそらく間違った実装は私には意味をなさない)。私もthisソリューションを試しましたが、期待通りに動作しません。私が探しているのは次のようなものです:
if sourceView == tableView {
//first tableView implementation
} else {
//second tableView implementation
}
何か助けていただければ幸いです。私は最後の4時間頭をひっぱっている。
魅力的な作品です!ありがとう! –