2014-08-28 40 views
5

我一直在iOS 7應用程序中使它與ios 8(beta 5)兼容。在此應用中,UIViewControllervc1)呈現另一個UIViewControllervc2)。 vc1支持縱向和橫向方向; vc2僅支持縱向。當提供vc2時,它要求vc1shouldAutorotateToInterfaceOrientation:並且這返回YESUIViewController設備旋轉委託方法沒有在iOS8中調用

在iOS8(Beta 5)中,willRotateToInterfaceOrientation:didRotateFromInterfaceOrientation:沒有被調用,以及新的iOS 8 API方法viewWillTransitionToSize。但是,這在iOS7中運行良好。

我知道willAnimateRotationToInterfaceOrientationdidRotateFromInterfaceOrientation在iOS 8中已棄用,但即使是iOS 8委託方法也沒有被調用。每當從vc1啓動vc2時,屏幕始終僅以縱向模式加載,儘管我提到支持的界面方向爲橫向模式。

任何想法...是否是iOS8中的錯誤?

+0

您可能想看看這個http://stackoverflow.com/questions/25238620/ios-8-rotation-methods-deprecation-backwards-compatibility – rahulinaction 2014-08-29 05:26:33

+0

通過此鏈接http://stackoverflow.com/問題/ 25935006/iOS8上的界面旋轉的方法而不是所謂的 – 2015-07-14 06:07:01

回答

2

嗯,我沒有弄清楚你的問題最好,但儘快我有一堆線在iOS 8.1中正常工作,我會將它們呈現給你。他們只是從Apple API參考手冊中進行了一些編輯。

簡單地說,我把它放在每個VC中,我只是在需要時編輯代碼。例如,我有一個應用程序,它具有縱向的初始視圖控制器,然後將VC更改(完成漸變)到具有不同功能的LandscapeVC。 這是在LandscapeView中導致旋轉的縱向視圖方法。

bool isShowingLandscapeView = false; 

- (void)awakeFromNib 
{ 
    isShowingLandscapeView = NO; 
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(orientationChanged:) 
               name:UIDeviceOrientationDidChangeNotification 
               object:nil]; 
} 

- (void)orientationChanged:(NSNotification *)notification 
{ 
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; 
    if (UIDeviceOrientationIsLandscape(deviceOrientation) && 
     !isShowingLandscapeView) 
    { 
     isShowingLandscapeView = YES; 
     [self performSegueWithIdentifier:@"toLandscape" sender:self]; 
    } 

我希望我理解起來很簡單。不要猶豫,以改善我的答案,我們都在今生學習!

相關問題