开发者

how to link view controller and .xib file to tab bar item in xcode 4

I have a tab bar with 4 items and i want to link the .xib files to each item. The problem is that the NIB File Name shows no items, and if i writ开发者_运维知识库e the .xib for example, StartView without the .xib i get an error. I get the same error when i link the tab item to the view controller class in the Identity Inspector. This is the error:

'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "StartView" nib but the view outlet was not set.'

I had no problem with this in Xcode 3. As far as i know i don't need outlets in my view controller to be able to link a view to a bar item.

Any ideas on how to fix this?

Thanks.


Each .xib has a main view that must be connected to its files owner. Usually when you change the class name of a .xibs owner, the view outlet will become disconnected. So you'll want to first check that the class name of your .xib is the custom controller you have made. You then have to open the .xib and click on the connections inspector. Then just drag and connect the view outlet (labelled as view in the connections inspector) to your view.

Cheers.


Problem solved, but i didn't like the solution. I created the view controller again and selected to create a .xib file along with the controller and that was it. Then i made the usual references from interface builder and it's working. I didn't like it because the .xib file has the same name as the view controller class. If anyone knows how to create the .xib file and the view controllers separately and get it to work, please inform me, i would really appreciate it.


select create new file, objective c, check the make xib file box and in the name of it, add .xib extension to the end of the name

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜