Supporting both iOS 6 and iOS 5 autorotation

后端 未结 6 1384
-上瘾入骨i
-上瘾入骨i 2020-12-06 05:46

Can anyone confirm that to support both iOS 6 and iOS 5 there is no point to adding the new iOS 6 autorotation methods, since the Apple docs suggest that these methods are c

6条回答
  •  猫巷女王i
    2020-12-06 06:38

    to support autorotations in both ios5 and ios6 we need to provide call backs in case of ios6....

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orientationChanged:) 
        name:UIDeviceOrientationDidChangeNotification object:nil];
    

    and we need to call

    - (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
    
    } 
    
    -(BOOL)shouldAutoRotate{
        return YES;
      }
    

    for ios5

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    {
    return ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
    }
    

提交回复
热议问题