3D 터치를 사용하려고합니다. 스크롤 할 때 아래 기능을 제외하고는 모든 것이 정상입니다. indexPath
과 indexPathForRow(at: location)
을 올바르게 스크롤 할 수 없습니다. 이 함수는 사용자가 테이블을 스크롤했는지 여부를 알 수 없으며 항상 사용자가 앱에서 첫 번째 행으로 볼 수있는 첫 번째 행을 설정한다고 말할 수 없습니다.indexPathForRow가 올바른 값을 반환하지 않습니다.
내 코드 :
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
guard let indexPath = workoutTable?.indexPathForRow(at: location) else {return nil }
guard let cell = workoutTable?.cellForRow(at: indexPath) else {return nil }
guard let workoutDetailPeek = storyboard?.instantiateViewController(withIdentifier: "WorkoutDetailPeek") as? WorkoutDetailPeek else {print("else31"); return nil }
workoutDetailPeek.workoutId = "\(Int(workout[(indexPath as NSIndexPath).row].workoutId)!-2)"
workoutDetailPeek.preferredContentSize = CGSize(width: 400.0, height: 267.0)
previewingContext.sourceRect = cell.frame
return workoutDetailPeek
}
내가 다른 3D 터치 구현을 통해 있었지만이 기능에 나를 제외하고 모두를 위해 잘 작동 보인다.