I want to make my appliaction only in landscape orientation in ios (Both ios 5 and ios 6)

后端 未结 4 975
耶瑟儿~
耶瑟儿~ 2020-12-06 08:25

I have use the Xcode 4.5.1 and use this conditions

#define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 )
#define         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 08:58

    remove those preprocessors blocks and add this 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)); }
    

提交回复
热议问题