2017-01-20 2 views
2

iPhone에서 팝업을 표시하려고합니다. 내가 여기에서 발견하고 대리자 "adaptivePresentationStyle"을 사용하는 제안을 따르고 있지만이 함수는 호출되지 않으며 ViewController는 항상 전체 화면 모드로 표시됩니다. 나는 "UIPopoverPresentationControllerDelegate"이 있고 기능이 울부 짖는 소리 :스위프트 3 - adaptivePresentationStyle을 호출하지 않습니다.

그래서
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 

     let identifier = segue.destination.restorationIdentifier ?? "" 
     if identifier == "NavigationSetup" { 
      if let destinationNav = segue.destination as? UINavigationController { 
       let destination = destinationNav.topViewController as! SetupTableViewController 
       destination.popoverPresentationController?.delegate = self 
       destination.popoverPresentationController?.backgroundColor = UIColor.blue 
       if self.myApp.isIpad{ 
        destination.preferredContentSize = CGSize(width: 600, height: 620) 
       }else{ 
        destination.preferredContentSize = CGSize(width: 0.8 * self.view.frame.size.width, height: 0.8 * self.view.frame.size.height) 
       } 

       self.cellAnimations.fade(image: self.imageBlur, initOpacity: 0, endOpacity: 1, time: 0.3, completion: nil) 
       destination.setupDismiss = {[weak self]() in 
        if let weakSelf = self{ 
         weakSelf.cellAnimations.fade(image: weakSelf.imageBlur, initOpacity: 1, endOpacity: 0, time: 0.3, completion: nil) 
        } 
       } 

      } 
     } 

    } 
    func adaptivePresentationStyle(for controller:UIPresentationController) -> UIModalPresentationStyle { 
     print("adaptive was called") 
     return .none 
    } 

, 내가 여기서 무엇을 놓치고?

+0

나는 ... 당신이없는 생각 ...'popController.modalPresentationStyle = UIModalPresentationStyle.popover' – TonyMkenu

+0

이를 확인 .. http://stackoverflow.com/questions/39972979/popover-in-swift -3-on-iphone-ios/39975346 # 39975346 – TonyMkenu

+0

감사합니다.하지만 "destination"을 사용하고 있었고 "destinationNav"를 사용해야합니다. 지금 일하고있어. – ClaytonAV

답변

5

먼저해야 제시하면서, 확인이 라인이 호출되고 만들 수있는 중단 점을 설정 애니메이션 만들기를 제시하지 않았다 :

destination.popoverPresentationController?.delegate = self 

는 더 나은, 다음과 같이 재 작성하고, 내부 선이 호출되고 있는지 확인하기 위해 중단 점을 설정합니다

if let pop = destination.popoverPresentationController { 
    pop.delegate = self 
} 

괜찮 으면! 이 경우 문제는 아마도 잘못된 대리자 메서드를 구현하는 것일 수 있습니다. 당신이 원하는 :

func adaptivePresentationStyle(for controller: UIPresentationController, 
    traitCollection: UITraitCollection) -> UIModalPresentationStyle { 
+0

고마워, 너 말이 맞아. "목적지"가 아닌 "destinationNav"를 사용해야 해. – ClaytonAV

0

아마 당신은 잘

let vc = UIViewController() 
vc.modalPresentationStyle = .custom; 
vc.transitioningDelegate = self; 
self.present(vc, animated: true, completion: nil) 

사용자 정의 모달 프리젠 테이션으로 제시하고 트릭을