gpt4 book ai didi

iphone - 横向时 BAD_ACCESS

转载 作者:行者123 更新时间:2023-11-28 19:19:28 24 4
gpt4 key购买 nike

我想保留我的风景。为此,我正在使用此代码,但 BAD_ACCESS 即将到来。在这里,我正在为相机 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];
}

为什么它给出 BAD ACCESS ?

最佳答案

要保持横向 View ,只需在 shouldAutorotateToInterfaceOrientation: 纵向方法中返回 NO,例如 tihs :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

关于iphone - 横向时 BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10087760/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com