2017-06-02 57 views
-1

首先,我遵循本教程:https://www.youtube.com/watch?v=B9sH_VxPPo4,然後我在一個真正的項目中使用此過渡,我工作,但自那時起,我面臨一個問題它。一個我不明白爲什麼會發生的問題。也許你可以幫助我。轉換後的視圖控制器是適合其大小類的限制,而不是設備

發生了什麼是以下幾點:我正在爲使用此轉換的應用程序製作教程。在設置教程文本的視圖控制器中,我將頂部,底部,前導和尾部約束設置爲0.因此,它應該將視圖控制器適合邊緣,對吧?但只有當我在尺寸類中選擇了我在模擬器中使用的相同設備時纔會發生這種情況。例如,我必須運行iPhone 7 plus模擬器並將尺寸類別設置爲iPhone 7以正常工作。當我在界面生成器中沒有改變任何東西的情況下運行iPhone 7的模擬器時,它崩潰了。我意識到視圖控制器不適合設備的邊緣(模擬或物理),它適合尺寸等級的邊緣。我意識到,當我用「.transitioningDelegate = self和.modalPresentationStyle = .custom」評論這些行時,它會像它應該那樣工作(但當然沒有過渡)。我認爲這可能是這個轉變的一個問題。你能幫我嗎?

這裏不用我使用的這個過渡呈現視圖控制器的代碼片段:

let levelTutorial = CPQuizLevelTutorialViewController() 
levelTutorial.transitioningDelegate = self 
levelTutorial.modalPresentationStyle = .custom 
self.present(levelTutorial, animated: true, completion: nil) 

在這裏做了我的代碼另一部分,我實現UIViewControllerTransitioningDelegate:

extension CPMainQuizViewController: UIViewControllerTransitioningDelegate { 

    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { 
     transition.transitionMode = .dismiss 
     transition.startingPoint = self.view.center 
     transition.circleColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha:0.6) 

     return transition 
    } 

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { 
     transition.transitionMode = .present 
     transition.startingPoint = self.view.center 
     transition.circleColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha:0.6) 

     return transition 
    } 
} 

Here is a picture of the interface builder. I put a blue background for facilitating the visualization of the problem

Here's what happens

我不知道它是否與錯誤有關,但我使用xib而不是Storyboard。我確實知道它與bug有關的一點是我對iOS開發很新穎。所以,首先,如果我說了一些愚蠢的話,對不起。 LOL

在此先感謝,夥計們!

回答

0

嗯,我找到了解決方法。後已經做了,屏幕行爲也完全調整其邊緣到智能電話邊緣

self.view.frame.size = CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) 

我加入這行代碼在每一個視圖控制器我是有這個問題。 :D

我仍然不知道是什麼導致了這個錯誤。所以,如果有人有任何想法,與我們分享。 :D

相關問題