开发者

UITabBarController, UIViewController and IB crash issue

开发者 https://www.devze.com 2023-01-18 16:50 出处:网络
I am writing an iPhone application that contains a tab controller, each tab item has a separated view controller and a xib file.

I am writing an iPhone application that contains a tab controller, each tab item has a separated view controller and a xib file.

It work normal when I only display views without any outlet connections from nib to my class. But when I try to connect items on the xib to my class variable. The application always crash.

The code is like:

@interface TabX : UIViewController {
 IBOutlet UILabel *label;
}

@property (nonatomic, retain) UILabel *label;

@end


@implementation PromotionNews

@synthesize label;

...

@end

The crash occurs when I make connection in IB to connect a Label object to my file owener's label outlet. The file owner is set to class TabX type.

Part of the trace is :

2010-09-30 10:23:59.503 MyNearByInfoApp[2613:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6d28530> setValue:forUndefinedKey:]: this class is not key value coding-compliant for 开发者_C百科the key label.'
*** Call stack at first throw:
(
 0   CoreFoundation                      0x02664b99 __exceptionPreprocess + 185
 1   libobjc.A.dylib                     0x027b440e objc_exception_throw + 47
 2   CoreFoundation                      0x02664ad1 -[NSException raise] + 17
 3   Foundation                          0x000330f3 _NSSetUsingKeyValueSetter + 135
 4   Foundation                          0x00033061 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
 5   UIKit                               0x004b170a -[UIRuntimeOutletConnection connect] + 112
 6   CoreFoundation                      0x025dad0f -[NSArray makeObjectsPerformSelector:] + 239
 7   UIKit                               0x004b0121 -[UINib instantiateWithOwner:options:] + 1041
 8   UIKit                               0x004b1eb5 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168

Any idea what this crash happen?


I just solved this error with another person JUST NOW. the problem is that you are referencing your views which do not match your code. and again its for the same reason. because you have a tab bar application im assuming you have the delegate as well and so on. what you do is click on the TAB BAR itself on the view and THEN name the class identity name as your class name that you use in xcode.

So delete the file owners class identity and leave it as normal. It should be UIApplication i believe if you used the default tabBar application.

Hope this helps Let me know if it does. Because it helped the other dude. Uts quite funny though how youre the second person that has the same problem. and its the first time im solving the same problem again one after the other. lol

PK

0

精彩评论

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

关注公众号