2012-10-03 27 views
1

我試圖交叉溶解,將SEGUE正常啓動並執行如預期動畫 - 然而,當在橫向模式下的目的地視圖控制器出現在其縱向佈局對動畫的持續時間。動畫完成後,目標視圖控制器會「捕捉」其橫向佈局。兩個視圖控制器均使用自動佈局進行設置。自動佈局與定製塞格斯與自定義賽格瑞兩個視點控制器之間

下面是我的自定義賽格瑞的「執行」的方法:

- (void)perform 
{ 
    UIViewController *srcController = self.sourceViewController; 
    UIViewController *dstController = self.destinationViewController; 
    dstController.view.transform = srcController.view.transform; 

    [UIView transitionFromView:srcController.view 
         toView:dstController.view 
        duration:self.animationDuration 
        options:self.animationOptions 
        completion:self.animationCompletionBlock]; 
} 

是否需要手動告訴目的地視圖控制器顯示之前觸發自動佈局?如果是的話,這將如何執行?使用內置的segue與cross-dissolve似乎沒有遇到這個問題,我試圖(沒有成功)來確定它在做什麼,我的自定義segue不是。

這把我難倒了一段時間,任何幫助,將不勝感激,並請讓我知道如果需要更多的細節。

回答

2

所以事實證明,解決這個問題比我想象的更簡單。加入以下行確保目的地視圖控制器已經右界限時,它勾畫出它的元素:

dstController.view.bounds = srcController.view.bounds; 

因此,代碼的其餘部分變爲:

- (void)perform 
{ 
    UIViewController *srcController = self.sourceViewController; 
    UIViewController *dstController = self.destinationViewController; 
    dstController.view.transform = srcController.view.transform; 
    dstController.view.bounds = srcController.view.bounds; 

    [UIView transitionFromView:srcController.view 
         toView:dstController.view 
        duration:self.animationDuration 
        options:self.animationOptions 
        completion:self.animationCompletionBlock]; 
} 
相關問題