我希望我的应用支持 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/