我不能想出这一个.我在IB中创建了一个定制的UItableVIEwCell.据我所知,我将所有的UILabels的所有对象正确连接在一起,并且所有的对象都建立在没有任何错误的情况下.当我尝试使用自定义单元格时,当我尝试加载NIB时,该应用停止.我列出了我在下面的地方.
任何帮助或提示或在哪里寻找这一个,将不胜感激.
谢谢,
约翰
这是我的UItableVIEwCell接口和实现方法.我不知道我真的需要分配init标签.我试过两种方式…
// ArrivalTimesCell.h#import <UIKit/UIKit.h>@interface ArrivalTimesCell : UItableVIEwCell { IBOutlet UILabel *cityArrivalTimeLabel; IBOutlet UILabel *optimumArrivalTimeLabel; IBOutlet UILabel *arrivalAvoIDTimesLabel; IBOutlet UILabel *arrivalTimeNotSetLabel;}@property (nonatomic,retain)IBOutlet UILabel *cityArrivalTimeLabel;@property (nonatomic,retain)IBOutlet UILabel *optimumArrivalTimeLabel;@property (nonatomic,retain)IBOutlet UILabel *arrivalAvoIDTimesLabel;@property (nonatomic,retain)IBOutlet UILabel *arrivalTimeNotSetLabel;@end// ArrivalTimesCell.m#import "ArrivalTimesCell.h"@implementation ArrivalTimesCell@synthesize arrivalTimeNotSetLabel,arrivalAvoIDTimesLabel,optimumArrivalTimeLabel,cityArrivalTimeLabel;- (ID)initWithStyle:(UItableVIEwCellStyle)style reuseIDentifIEr:(Nsstring *)reuseIDentifIEr{ self = [super initWithStyle:style reuseIDentifIEr:reuseIDentifIEr]; if (self) { arrivalTimeNotSetLabel = [[UILabel alloc] init]; arrivalAvoIDTimesLabel = [[UILabel alloc] init]; optimumArrivalTimeLabel = [[UILabel alloc] init]; cityArrivalTimeLabel = [[UILabel alloc] init]; } return self;}- (voID)setSelected:(BOol)selected animated:(BOol)animated{ [super setSelected:selected animated:animated];}- (voID)dealloc{ [super dealloc]; [arrivalTimeNotSetLabel release]; arrivalTimeNotSetLabel = nil; [arrivalAvoIDTimesLabel release]; arrivalAvoIDTimesLabel = nil; [optimumArrivalTimeLabel release]; optimumArrivalTimeLabel = nil; [cityArrivalTimeLabel release]; cityArrivalTimeLabel = nil;}@end
这是UItableVIEw的cellForRowAtIndexPath的一部分
// TripEditVIEwController.m#import "ArrivalTimesCell.h"@implementation TripEditVIEwController- (UItableVIEwCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath { CellIDentifIEr = @"ArrivalTimesCell"; ArrivalTimesCell *cell = (ArrivalTimesCell *)[tableVIEw dequeueReusableCellWithIDentifIEr:CellIDentifIEr]; if(cell == nil){ NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibnamed:@"ArrivalTimesCell" owner:nil options:nil]; for (ID currentObject in topLevelObjects) { if ([currentObject isKindOfClass:[UItableVIEwCell class]]) { cell = (ArrivalTimesCell *) currentObject; break; } } } cell.cityArrivalTimeLabel.text = @"Whatever" cell.arrivalAvoIDTimesLabel.text = @"Whatever"; cell.optimumArrivalTimeLabel.text = @"Whatever"; cell.arrivalTimeNotSetLabel.text = @"Whatever"; return cell; }
程序执行停止在loadNibnamed行上,而控制台中没有任何注释.如果我“进入”我得到以下,我不知道与我的崩溃的原因有关,而是由于nib的加载不正确的结果…
解决方法 在你的笔尖的某处,你可以在没有该属性的对象上连接到cityArrivalTimeLabel属性.确保您将单元格的类更改为ArrivalTimesCell,并将该标签连接到正确的对象.2011-03-29 12:18:14.137 JetLogger[4565:207] * Terminating app due to uncaught exception ‘NSUnkNownKeyException’,reason: ‘[ setValue:forUndefinedKey:]: this class is not key value Coding-compliant for the key cityArrivalTimeLabel.’
* Call stack at first throw:
(
0 CoreFoundation 0x0111a5a9 exceptionPreprocess + 185
1 libobjc.A.dylib 0x0126e313 objc_exception_throw + 44
2 CoreFoundation 0x0111a4e1 -[NSException raise] + 17
3 Foundation 0x000ca677 _NSSetUsingkeyvalueSetter + 135
4 Foundation 0x000ca5e5 -[NSObject(NSkeyvalueCoding) setValue:forKey:] + 285
5 UIKit 0x0054e30c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x010908cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x0054cd23 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x0054eab7 -[NSBundle(UINSBundleAdditions) loadNibnamed:owner:options:] + 168
9 JetLogger 0x0004bf18 -[TripEditVIEwController tableVIEw:cellForRowAtIndexPath:] + 699
10 UIKit 0x003c7b98 -[UItableVIEw(UItableVIEwInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
11 UIKit 0x003bd4cc -[UItableVIEw(UItableVIEwInternal) _createPreparedCellForGlobalRow:] + 75
12 UIKit 0x003d28cc -[UItableVIEw(_UItableVIEwPrivate) _updateVisibleCellsNow:] + 1561
13 UIKit 0x003ca90c -[UItableVIEw layoutSubvIEws] + 242
14 QuartzCore 0x02051a5a -[CALayer layoutSublayers] + 181
15 QuartzCore 0x02053ddc CALayerLayoutIfNeeded + 220
16 QuartzCore 0x01ff90b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
17 QuartzCore 0x01ffa294 _ZN2CA11Transaction6commitEv + 292
18 QuartzCore 0x01ffa46d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
19 CoreFoundation 0x010fb89b __CFRUNLOOP_IS_CALliNG_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 27
20 CoreFoundation 0x010906e7 __CFRunLoopDoObservers + 295
21 CoreFoundation 0x010591d7 __CFRunLoopRun + 1575
22 CoreFoundation 0x01058840 CFRunLoopRunspecific + 208
23 CoreFoundation 0x01058761 CFRunLoopRunInMode + 97
24 GraphiCSServices 0x01a081c4 GSEventRunModal + 217
25 GraphiCSServices 0x01a08289 GSEventRun + 115
26 UIKit 0x00360c93 UIApplicationMain + 1160
27 JetLogger 0x00001ba8 main + 102
28 JetLogger 0x00001b39 start + 53
)
terminate called after throwing an instance of ‘NSException’
您不需要在init方法中分配/初始化标签.它们只是在笔尖加载时才被替换,所以直到那时才会浪费RAM.
总结以上是内存溢出为你收集整理的iphone – 崩溃[[NSBundle mainBundle] loadNibnamed:owner:options:]全部内容,希望文章能够帮你解决iphone – 崩溃[[NSBundle mainBundle] loadNibnamed:owner:options:]所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)