Made a change in Interface Builder, Xcode is not showing it

扶醉桌前 提交于 2019-12-12 18:08:58

问题


So here is what my interface looks like at the moment:

Here is what I have changed it to in Interface Builder:

This is what is shown after I run it in Xcode:

Obviously the two programs are not communicating - if someone could point me in the right direction it would be great.

Thanks heaps!


回答1:


If stuff isn't in sync, try cleaning your build. Product>Clean should do the trick.




回答2:


The programs communicate through the NIB/XIB files. Make sure you have saved your changes from Interface Builder before rebuilding in XCode (this does not happen automatically). Also double check that the file Interface Builder is editing is the exact same file (not a copy) of the one in your XCode project.

Hope this helps.




回答3:


This happens if you rename a nib but forget to change name of nib name passed in to a ViewController in its initWithNibName: bundle initialiser.

For example. If I have a nib named ViewOne.xib which I'm passing in to a ViewController like this:

ExampleViewController *exampleViewController = [[ExampleViewController alloc] initWithNibName:@"ViewOne" bundle:nil];

And I change the name of the nib to ViewTwo, Xcode isn't smart enough to amend this reference in the initialiser, so now a xib that noi longer exists is being passed in to the ViewController. For reasons that I cannot fathom, despite the fact there is no longer a nib called ViewOne.xib, Xcode maintains some sort of ghost of the file and you won't get an error because of the missing nib. Cleaning and deleting derived data did not get rid of this ghost reference, at least in my case.

The fix is easy - just amend the nib name in the initialiser to your new name:

ExampleViewController *exampleViewController = [[ExampleViewController alloc] initWithNibName:@"ViewTwo" bundle:nil];


来源:https://stackoverflow.com/questions/5956907/made-a-change-in-interface-builder-xcode-is-not-showing-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!