iOS 7 Interface Orientation

后端 未结 2 1895
北海茫月
北海茫月 2020-12-01 22:26

I have an app that is always showed in portrait mode.

But in somewhere i have a media gallery that must support landscape.

The supported orientation by defau

2条回答
  •  情歌与酒
    2020-12-01 23:01

    In my app for iPhone its only support the portrait view only, but as per requirement need to support landscape view only for on view, at that time I use following way and its help me :

    In your app delegate .h

    @interface PlayWithWSWithLibAppDelegate : NSObject  {
    
           BOOL flagOrientationAll;
    }
    
    @property (assign) BOOL flagOrientationAll;
    

    Add following method in your app delegate .m file

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
        //NSLog(@"PlayWithWSWithLibAppDelegate -- supportedInterfaceOrientationsForWindow");
        if([UICommonUtils isiPad]){
            return UIInterfaceOrientationMaskAll;
        }else if(flagOrientationAll == YES){
            return UIInterfaceOrientationMaskAll;
        } else {
            return UIInterfaceOrientationMaskPortrait;
        }
    }
    

    Implement following way in your view which you want to rotate in both portrait and landscape both for iPhone device

    -(void)viewWillAppear:(BOOL)animated
    {
        self.tabBarController.delegate = self;
    
        PlayWithWSWithLibAppDelegate *delegate = (PlayWithWSWithLibAppDelegate *) [[UIApplication sharedApplication] delegate];
        delegate.flagOrientationAll = YES;
     }
    }
    
    -(void)viewWillDisappear:(BOOL)animated
    {
        //NSLog(@"viewWillDisappear -- Start");
         PlayWithWSWithLibAppDelegate *delegate = (PlayWithWSWithLibAppDelegate *)[[UIApplication sharedApplication] delegate];
            delegate.flagOrientationAll = NO;
    }
    

    see this post also: How to set one of the screens in landscape mode in iphone?

提交回复
热议问题