今天看啥
热点:

ios 相机界面强制横屏


IOS调用系统的相机默认是竖屏的,网上找了很多方法强制横屏都无效,以下代码经测试兼容ios78

自定义一个UIImagePickerController并且覆盖以下方法:

 

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

return UIInterfaceOrientationLandscapeLeft;

}

 

- (NSUInteger)supportedInterfaceOrientations{

return UIInterfaceOrientationMaskLandscape;

}

 

- (BOOL)shouldAutorotate {

return YES;

}

 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) {

return YES;

} else {

return NO;

}

}

要兼容ios8还需要在delegate中加入以下代码

 

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

{

 

NSString* strSubClass = [NSString stringWithUTF8String:object_getClassName(window.rootViewController.presentedViewController)];

if ([@"ImgTakeViewController" isEqualToString:strSubClass]) {

return UIInterfaceOrientationMaskAll;

}

return [application supportedInterfaceOrientationsForWindow:window];

}


www.bkjia.comtruehttp://www.bkjia.com/IOSjc/970210.htmlTechArticleios 相机界面强制横屏 IOS调用系统的相机默认是竖屏的,网上找了很多方法强制横屏都无效,以下代码经测试兼容ios78 自定义一个UIImagePic...

相关文章

相关搜索: 界面 相机

帮客评论

视觉看点