2017-10-30 2 views
2

내비게이션 컨트롤러에 대한 사용자 정의 푸시 전환을 구현하고 싶습니다.snapshotView (afterScreenUpdates : true)가 빈 뷰를 반환합니다.

먼저 UINavigationControllerDelegate을 구현했으며 여기서 객체는 UIViewControllerAnimatedTransitioning입니다.

이 클래스에서는 대상 뷰의 스냅 샷을 애니메이트하려고합니다. 그러나 push-segue의 경우 스냅 샷이 비어 있습니다. [내가 다시 팝업 때 , 나는 afterScreenUpdates = false를 설정하고 모든 작동] -snapshotViewAfterScreenUpdates에 대한 사실 공급

guard let fromVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from), 
     let toVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) else { 
      return 
    } 

    guard let snapshot = toVC.view.snapshotView(afterScreenUpdates: true) else { 
     return } 

    // Problem: 
    // snapshot is an empty view! 

답변

0

: 실제로 이미지를 그려 다시 runloop로 여행을해야 의미합니다. NO를 입력하면 즉시 시도하지만 화면이 꺼져 있거나 화면에 아직 그려져 있지 않으면 스냅 샷이 비어 있습니다.

+0

"실제로는 이미지를 그릴 때 runloop으로 되돌아 가야한다는 것을 의미합니다 *"- 이것을 달성하는 방법에 대한 힌트가 있습니까? – Pascal

+0

@Pascal true를 사용하여이 작업을 수행 할 수 있지만 이미지를 즉시 보려는 경우 -snapshotViewAfterScreenUpdates에 false를 사용해야합니다. – SergStav

관련 문제