[英]BAD_ACCESS while landscape orientation
I want to keep my view landscape.我想保留我的风景。 For that i am using this code but BAD_ACCESS is coming.为此,我正在使用此代码,但 BAD_ACCESS 即将到来。 Here I am writing this code for camera overlayView.在这里,我正在为相机 overlayView 编写这段代码。
-(void)viewDidLoad
{
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
//Set Notifications so that when user rotates phone, the orientation is reset to landscape.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
//Refer to the method didRotate:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
[super viewDidLoad];
}
- (void) didRotate:(NSNotification *)notification
{
//Maintain the camera in Landscape orientation
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
}
Why it is giving BAD ACCESS?为什么它给 BAD ACCESS?
To keep your view landscape, just return NO
in your shouldAutorotateToInterfaceOrientation:
method for portrait orientations, like tihs:为了让你的视图保持横向,只需在你的shouldAutorotateToInterfaceOrientation:
纵向方法中返回NO
,比如 tihs:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.