Made a change in Interface Builder, Xcode is not s

2019-07-11 04:01发布

问题:

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

Start interface http://i54.tinypic.com/25876mr.png

Here is what I have changed it to in Interface Builder: Desired interface http://i51.tinypic.com/24qms9l.png

This is what is shown after I run it in Xcode: Resulting interface http://i54.tinypic.com/25876mr.png

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];