gpt4 book ai didi

ios - UIInterfaceOrientation Xcode

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

我希望我的应用支持 PortraitUpSideDown 方向。我更改了 info.p 列表以反射(reflect)这一点,并尝试在一个 View 上实现更改作为测试

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
return YES;
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
return YES;

}

但是 View 没有响应。在应用程序响应之前,我是否需要在所有 View 上实现它?我需要更改 Xib 设置吗?

最佳答案

如果您想同时支持横向,请尝试以下操作:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}

或者:

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

或者看起来像您要写的东西:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
return YES;
}
if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
return YES;
}
return NO;
}

关于ios - UIInterfaceOrientation Xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9539425/

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