gpt4 book ai didi

ios - 替代私有(private)-[UIDevice setOrientation :] for forcing camera overlay into portrait mode

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:58:20 24 4
gpt4 key购买 nike

我正在为 iPad 制作相机应用。我希望相机应用程序仅在纵向模式下工作。我不得不进行旋转观察,并强制设备像这样使用纵向模式:

UIImagePickerController in Landscape

我认为这是私有(private) API;帖子中的一些用户认为是。

如果是这样,我还可以使用其他什么解决方法来强制叠加层仅保持纵向模式?如果我不添加此代码,它会旋转到纵向和横向模式。

    //Is this private?
@interface UIDevice ()
-(void)setOrientation:(UIDeviceOrientation)orientation;
@end

-(IBAction)InitiateCamera
{

overlayview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
...
...

//monitor device rotation
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];




//launch camera
[self presentViewController:picpicker animated:YES completion:nil];


}



- (void) didRotate:(NSNotification *)notification
{


//IS THIS PRIVATE?
//Maintain the camera in portrait orientation
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];

}

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

-(NSUInteger)supportedInterfaceOrientations
{

return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}

最佳答案

请改用此代码。我提交了一个应用程序,它在 iTunes 上获得了批准

- (void) didRotate:(NSNotification *)notification
{
[[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:") withObject:(__bridge id)((void*)UIInterfaceOrientationPortrait)];

}

关于ios - 替代私有(private)-[UIDevice setOrientation :] for forcing camera overlay into portrait mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22132733/

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