gpt4 book ai didi

ios - 仅在一个 UIViewController 上强制横向 View

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

我有一个只有纵向模式的应用程序。我只有一个 View Controller 需要强制进入横向模式(客户签名 View ),这样客户就有更多的空间来签名。

如何强制一个 ViewController 以横向模式显示。让其余部分保持纵向?

我已尝试将应用程序的一般部署信息设置为纵向、横向左侧

enter image description here

然后在签名 View 上使用此代码

- (BOOL)shouldAutorotate {
return YES;
}

并在所有其他 View Controller 上返回 NO。但这似乎没有用。

我还包括了

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

这可能吗?

最佳答案

在签名 View Controller 中尝试这段代码

 - (void)viewDidLoad
{
[super viewDidLoad];
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationLandscapeLeft] forKey:@"orientation"];
}

-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationPortrait] forKey:@"orientation"];
}

关于ios - 仅在一个 UIViewController 上强制横向 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38487124/

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