weird error when connecting in Interface Builder
i am getting a weird error when i connect my outlets in my xib.
I have a tab bar app, with 3 tabs. the first two work perfectly, but the third tab is having problems - it crashes the app when you push it 开发者_Python百科when any IBOutlets are connected in IB. if you remove the connections, but leave them declared in xcode then it works fine. but as soon as i connect them again, it crashes the app.
any thoughts?
********** added code *********
.h
@interface Orders : UIViewController {
UILabel *username, *customer;
}
@property (nonatomic, readonly) IBOutlet UILabel *username, *customer;
.m
@implementation Orders @synthesize username, customer;
message from console
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key username.'
Your posted code shows the UILabels are called customer
and username
but the screenshot shows them called customerLabel
and usernameLabel
in the nib file. Make sure that you're using the same names for the views everywhere (I recommend appending "Label" to the end of the names if they are UILabels. Better to have descriptive names.).
And like Kirby says in a comment to your question, make sure that the File's Owner in the nib file is set to be an instance of your UIViewController subclass (looks like it's called "Orders" but it should really be something like "OrdersViewController").
精彩评论