码迷,mamicode.com
首页 > 其他好文 > 详细

横屏下的ImagePickerController

时间:2014-10-20 14:44:23      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:io   ar   for   strong   sp   on   代码   amp   ef   

Try this way....

As per Apple Document, ImagePicker Controller never Rotate in Landscape mode. You have to use in Potrait Mode only.

For disable Landscape mode only for ImagePicker Controller follow below code.

In your ViewController.m

Make the SubClass(NonRotatingUIImagePickerController) of Image Picker Controller

@interface NonRotatingUIImagePickerController : UIImagePickerController

@end

@implementation NonRotatingUIImagePickerController
// Disable Landscape mode.
- (BOOL)shouldAutorotate
{
    return NO;
}
@end

Use as follow

UIImagePickerController* picker = [[NonRotatingUIImagePickerController alloc] init];
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        picker.delegate = self; 
  etc.... Just as Default ImagePicker Controller

This is working for me & Let me know if you have any Problem.

 

 

补充,需要再AppDelegate下面添加如下代码:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

    return UIInterfaceOrientationMaskAll;

}

横屏下的ImagePickerController

标签:io   ar   for   strong   sp   on   代码   amp   ef   

原文地址:http://www.cnblogs.com/scaptain/p/4036984.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!