How to change view of the viewcontroller when change the orientation in iPhone?

后端 未结 3 888
悲哀的现实
悲哀的现实 2021-01-28 19:13

I\'m developing an iPhone application which supports 2 orientations. I have 2 UIView files for this view controller. I need to set corresponding UIView file to the view controll

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-28 19:56

    Why do you want to use two views for both orientation? You can set autoresizemask properties of controls, if portrait and landscape both mode has similar control to be show at same place. Otherwise, you need to use two views in

    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
    

    or you can have notification of UIDevice

     UIKIT_EXTERN NSString *const UIDeviceOrientationDidChangeNotification;
    
    - (void)beginGeneratingDeviceOrientationNotifications;      // nestable
    - (void)endGeneratingDeviceOrientationNotifications;
    

提交回复
热议问题