Force landscape orientation in UIImagePickerController

前端 未结 3 1075
耶瑟儿~
耶瑟儿~ 2020-11-27 21:11

I\'m new to iOS development, and Im developing my first app. (so sorry if Im asking a newbie question)

My app is all in portrait orientation, except to the place whe

3条回答
  •  暖寄归人
    2020-11-27 21:41

    Create a class named "CUIImagePickerController" inherited from UIImagePickerController, override following methods, now use this class!

    @interface CUIImagePickerController : UIImagePickerController
    
    @end
    
    @implementation CUIImagePickerController
    - (BOOL)shouldAutorotate {
        return NO;
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient {
        return (orient == UIInterfaceOrientationLandscapeLeft) | (orient == UIInterfaceOrientationLandscapeRight);
    }
    @end
    

    Regards,

提交回复
热议问题