내 뷰 컨트롤러를 소스 테이블로 테이블 뷰에 등록하여 앱에서 3D 터치를 구현했습니다. 그리고 그것을 구현 한 이후 지난 2 주 동안 잘 작동했습니다.3D 터치 뷰 컨트롤러가 호출되지 않습니다.
하지만 방금 시도한 결과 더 이상 작동하지 않는 것으로 나타났습니다. 그 코드를 건드리지 않았으므로 문제가 무엇인지 알지 못합니다.
보기 컨트롤러가 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()
에서 호출 내가 미리 등록 코드입니다 :
if traitCollection.forceTouchCapability == .Available {
registerForPreviewingWithDelegate(self, sourceView: tableView)
}
고마워,하지만 그 프로젝트에서 아직 스위프트 3으로 업데이트하지 않았다. (아직이 문제가 무엇인지 알아 내지 못했다.) – CompC
아 맞다. viewControllerForLocation 대리자 함수를 공유하면 작동하는 버전으로 확인할 수 있습니다. –
원본 코드에 내 코드를 추가했습니다. – CompC