【问题标题】:Xcode 7: Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' vs 'NSUInteger'Xcode 7:“supportedInterfaceOrientations”实现中的返回类型冲突:“UIInterfaceOrientationMask”与“NSUInteger”
【发布时间】:2015-09-19 17:50:44
【问题描述】:

我刚刚将我的 Xcode 更新到版本 7.0 (7A220),不幸的是,我遇到了几个问题。让我列出这些:

  1. 现在 images.xcassets支持 1x、2x、3x。现有图像的 Retina 4 2x 框仍然存在,但您无法添加具有 Retina 支持的新集。我该如何处理?
  2. 我的应用程序不再工作适用于 iPhone 4* 和 5*。图像消失:我只能看到文本(实际上只有启动屏幕图像有效)。我猜我可能对 iPhone 5* 有问题(不再支持 Retina 4),但我对 iPhone 4* 感到惊讶(我曾经为每个图像创建一个 -480 版本并放入 2x 盒子中)。这里有同样的问题:我该如何处理?
  3. 我收到了几个警告:第一个是关于“更新到推荐的项目设置”(已完成,但没有任何改变)。

第二个是在运行时:

../ViewController.m:41:1: Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' (aka 'enum UIInterfaceOrientationMask') vs 'NSUInteger' (aka 'unsigned int')

第三个也在运行时:

(null): Directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks'

有人可以帮助我吗?我正在使用 Xcode 7.0 (7A220) 和 SpriteKit 来开发我的应用程序。

【问题讨论】:

  • 太多问题合二为一。这应该是三个问题;没有有用的方法来回答这个问题。 (2) 中的信息太模糊:“不再起作用”毫无意义。
  • 编号 (1) 的相同问题,图片资源

标签: ios iphone sprite-kit xcode7


【解决方案1】:

这就是我解决这些问题的方法:

1) Apple 似乎不再支持 Retina 4。这意味着 iPhone 4*、iPhone 5* 和 iPhone 6 需要放在 @2x 框内。当然,处理全屏图像比较棘手,因此您必须以编程方式处理所有图像。

2) 我通过将所有图像设置为“通用”而不是特定设备(iPhone 4S 和 5。不知道为什么,但 iPhone 6 即使在特定设备上也能正常工作)解决了这个问题.不管怎样,不管有没有 bug,我已经通知了 Apple。

3a) 方法UIInterfaceOrientationMask的返回类型发生了变化,所以如果遇到../ViewController.m:41:1: Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' (aka 'enum UIInterfaceOrientationMask') vs 'NSUInteger' (aka 'unsigned int')这样的警告,需要更换返回类型。

// Before upgrading
- (NSUInteger)supportedInterfaceOrientations
{
    ...
}

// After upgrading
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    ...
}

(感谢 Rainer Schwarze

3b) 升级似乎在自定义框架上下文中产生了问题(如果我错了,请纠正我),这可以通过删除构建设置中的引用来解决。

希望这会有所帮助!

【讨论】:

  • 嗨!非常感谢您的回答,我被其中一些问题困住了,这真的很有帮助。但我不确定你是如何处理第二点的。你如何将图像设置为通用?你能更详细地解释一下吗?对不起我的英语不好,提前谢谢!
【解决方案2】:

试试这个界面方向警告:

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000  
- (NSUInteger)supportedInterfaceOrientations  
#else  
- (UIInterfaceOrientationMask)supportedInterfaceOrientations  
#endif  
{
    return UIInterfaceOrientationMaskPortrait;
}

【讨论】:

  • 感谢分享:)
  • 应该被接受,因为它允许向后编译兼容性。
【解决方案3】:

我可以给出这个警告的提示:

实现中的返回类型冲突 'supportedInterfaceOrientations':'UIInterfaceOrientationMask'(又名 'enum UIInterfaceOrientationMask')与'NSUInteger'(又名'无符号' int')

您需要将方法supportedInterfaceOrientations 的返回类型NSUInteger 替换为UIInterfaceOrientationMask。返回类型已从 iOS8 更改为 iOS9。:

- (UIInterfaceOrientationMask) supportedInterfaceOrientations
{
    ...
}

编辑:

最终我在使用该类型的 .m 文件的实现部分之前使用了它:

// Make compilable on iOS8:
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
#define UIInterfaceOrientationMask NSUInteger
#endif

这将条件语句保留在一个位置,并且一旦 iOS8 支持被删除,sn-p 就可以轻松删除。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-05
    • 1970-01-01
    • 2021-10-23
    相关资源
    最近更新 更多