ios - UIInterfaceOrientation Xcode

标签 ios cocoa-touch uiinterfaceorientation

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

相关文章:

ios - UIViewController 在纵向模式下空白,但 subview 在横向模式下可见?

ios - 如何跨多个应用程序识别 iOS 设备?

ios - iMessage 导航 Controller 栏在展开时隐藏

ios - UIBarButtonItem 色调颜色 iOS4

iphone - iPhone 上的 Flash(或 Silverlight)

ios - 在 ipad ios 5.0 版本中无法以横向模式显示应用程序

ios - 左侧的 UITableView 滚动指示器

ios - 如何自定义注册远程推送通知时的弹出消息

iphone - 为此我需要哪种音频播放技术?

iOS7 iPad Landscape only app,使用 UIImagePickerController