私のアプリはコアデータオブジェクトに異なる属性を格納します。それらはすべてUITableViewに表示されます。セルをクリックするとDetailViewが表示されます。 Master-Detail-XCode-Templateのような通常のものです。3D Touch PeekとPopからUITableViewCellへデータを他のUIViewControllerに渡す方法は?
今、3Dタッチをpeekとpopで実装したいと考えています。メールアプリケーションのように、3Dタッチセル、プレビューを取得し、詳細を押し、深く押してください。
私がこれまでに取り組んでこれを得たが、私はトン、他のDetailViewControllerに
- (nullable UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location
と
- (void)previewingContext:(id <UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit
に対応するデータを渡す方法を見つけ出すことができます。
あなたはちょうど私が
id detailItem
おきのViewControllerでを使用していますが、私はそれに対応するオブジェクトを設定し、私は
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath];
[[segue destinationViewController] setDetailItem:object];
にデータを引き渡すセル(なし3Dタッチ)をクリックした場合。
私はDetailViewControllerの "detailItem"に、選択した(3Dタッチされた)セルから対応するCore Dataオブジェクトが必要なので、仕事に似たものを得ようとします。
ありがとうございました!
おかげで、私は本当に近かったけど...アップ何かを台無し;あなたはあなたからのコードのこの部分を取ったことは言及しなかった) – Kreuzberg
@Dheerajディレクトリサー林檎。自己sourceView:self.tableView https://developer.apple.com/library/content/samplecode/ViewControllerPreviews/Listings/Projects_PreviewUsingDelegate_PreviewUsingDelegate_MasterViewController_UIViewControllerPreviewing_swift.html#//apple_ref/doc/uid/TP40016546-Projects_PreviewUsingDelegate_PreviewUsingDelegate_MasterViewController_UIViewControllerPreviewing_swift-DontLinkElementID_6 –