自分のアプリケーションで3Dビューを実装しました。ビューコントローラをソースビューとしてテーブルビューに登録しました。そして、私はそれを実装して以来、過去数週間は正常に動作しています。3D Touch View Controllerが呼び出されていない
しかし、私はそれを試したところ、もはや動作していないように見えました。私はそのコードのどれにも触れなかったので、何が問題なのか分かりません。
ビューコントローラが確実にUIViewControllerPreviewing
に登録されていますが、previewingContext(previewingContext: viewControllerForLocation:)
は呼び出されていません。
これをプレビューのために登録とは別に設定する必要があるかどうかわかりません。その方法をトリガーするものは何もありません。私は3Dタッチがうまく動作しているように見える別のビューコントローラを持っていますが、私は別のことをやっていません。
誰かが、なぜメソッドが呼び出されていないのかについてのアイデアはありますか?以前はうまく働いていたので、仕事が止まったように見えるので、これは本当にイライラしています。ありがとう。ここで
は私のpreviewingContext(previewingContext: viewControllerForLocation:)
メソッドのコードされています
func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
let identifier = "ClipPlayerViewController"
guard let indexPath = tableView.indexPathForRowAtPoint(location), let destination = storyboard?.instantiateViewControllerWithIdentifier(identifier) as? ClipPlayerViewController else { return nil }
let effect = filteredEffectsSortedBySection[indexPath.section].effects[indexPath.row]
switch effect.mediaType {
case .Video:
destination.effect = effect
destination.showsPlaybackControls = false
if let thumbnail = thumbnailsForEffects[effect], let unwrappedThumbnail = thumbnail {
destination.preferredContentSize = CGSizeMake(unwrappedThumbnail.size.width - 2, unwrappedThumbnail.size.height - 2)
} else if let effectSize = destination.player?.currentItem?.asset.tracksWithMediaType(AVMediaTypeVideo).first?.naturalSize {
destination.preferredContentSize = effectSize
}
previewingContext.sourceRect = tableView.cellForRowAtIndexPath(indexPath)!.frame
return destination
case .Texture:
return nytPhotosViewControllerForEffectAtIndexPath(indexPath)
}
}
そして、ここではviewDidLoad()
に呼び出され、私はプレビューするための登録コードは、次のとおりです。あなたはSwift3に
if traitCollection.forceTouchCapability == .Available {
registerForPreviewingWithDelegate(self, sourceView: tableView)
}
ありがとうございますが、私はまだそのプロジェクトのSwift 3に更新していません(まだこれに関する問題は何も分かっていません) – CompC
ああ。あなたがviewControllerForLocationデリゲート関数を共有している場合は、私のバージョンが動作しているかどうか確認できます。 –
元の投稿に自分のコードを追加しました。 – CompC