【问题标题】:Loading device-specific iPad/iPhone UIViewController nib fails with .mm files加载特定于设备的 iPad/iPhone UIViewController nib 失败,带有 .mm 文件
【发布时间】:2012-12-13 17:42:34
【问题描述】:

编辑:我在下面写“类”的地方,我的意思是“类的实际类名”,而不是字面意义上的“类”!

对于通用应用程序中的 UIViewController,我们使用:

[[class alloc] initWithNibName:nil bundle:nil];

[[class alloc] init]; // same thing

文件:

  1. class~ipad.xib
  2. 类~iphone.xib

Apple 根据 Apple 文档正确加载特定于设备的 NIB。

但如果 UIViewController 有一个“.mm”扩展名,它每次都会失败。似乎只发生在 Obj-C++ 视图控制器上(更改文件扩展名“修复”它)。

【问题讨论】:

    标签: iphone ios ipad nib


    【解决方案1】:

    啊,自我回答,找到了一个可行的解决方法:

    代替:

    initWithNibName:nil bundle:nil
    

    使用:

    initWithNibName:@"class" bundle:nil // where "class" == your classname, no extension
    

    无论 Apple 的代码中基于文件名读取 NIB 文件的错误是什么......这似乎都修复了它

    【讨论】:

      猜你喜欢
      • 2023-03-26
      • 2013-03-27
      • 1970-01-01
      • 2011-06-12
      • 1970-01-01
      • 2011-05-05
      • 2012-02-01
      • 1970-01-01
      • 2015-01-21
      相关资源
      最近更新 更多