iphone - initWithNibName : bundle: always load English nib

标签 iphone objective-c cocoa-touch localization uiviewcontroller

我已将 ContactView.xib 文件本地化为英语和法语,通常必须自动加载。我使用UIViewController的initWithNibName:bundle:方法来初始化该对象,但结果总是一样:加载的文件是英文的!

我已经清理了项目,重新安装了应用程序等,但没有任何效果,我的 xib 文件的法语版本被简单地忽略了!

我知道有一个相关的帖子 ( here ),但问题并不完全相同,尽管我付出了努力,但问题仍然存在。

这是我编写的代码示例:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil contact:(Contact *)aContact
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self != nil)
    {
        self.contact = aContact;
    }
    return self;
}

是否还需要执行其他操作才能将文件加载到适当的区域设置中? 我已经检查了设备(或模拟器)上的首选项以及模块中加载的首选项,并且区域设置每次都设置为法语。

提前谢谢您,

杰弗罗伊。

最佳答案

我今天遇到了一个非常相似的问题,并浪费了大约 2 个小时。

At the end I deleted the localized xib through the "-" in the localization menu. Then I had to delete the .XIB file in the project

(在删除任何内容之前,请务必在某处保存它的副本 - 您无法将其恢复!!)。

Then I dragged the .XIB file back into the project. And finally it worked

毕竟我可以正确本地化并且它有效。但我告诉你,在应用程序未 200% 准备就绪之前,我永远不会开始本地化。 xCode4 似乎有一个严重的错误。 (它甚至在我身上崩溃了几次 - 我猜是因为它保留了一些 xib 的链接,但在 HDD 上的任何地方都找不到。

此错误仅在执行所描述的过程后才消失。即使从项目中删除 .XIB 文件并从 HDD 中删除它仍然没有帮助。 XCode 很高兴地开始使用这个 .XIB(无论它从哪里获得)。

祝你好运! (我今天在这上面浪费了太多时间!)

关于iphone - initWithNibName : bundle: always load English nib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5558259/

相关文章:

objective-c - 将监听器添加到 leftBarButtonItem

ios - 可能的循环引用?

iphone - 如何正确保留对 ActionSheet 委托(delegate)使用的对象的引用?

iphone - 多个 iAd 与一个 View Controller ?

ios - Fabric :/ios/Pods/Fabric/run”: No such file or directory

iphone - 最佳实践 : Fast UITableView Scrolling?

iphone - 重叠的 CAShapeLayer 轮廓

ios - 如何在 Interface Builder 中使用 UIScrollView?

iphone - 模态视图被替换

iphone - EAGLView 到 UIImage 颜色转换问题