У меня есть эта проблема, с которой я сижу. Мой tableView, который я ввел в UIView, не заполняется, или иногда я получаю исключение.UITableView, не заселяющий UIView
// .h
@interface List : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
UITableView *mTableView;
}
@property (nonatomic, readonly) IBOutlet UITableView *tableView;
//------------------------------
// .m
@synthesize tableView=mTableView;
//Further I do the normal viewDidUnload stuff = nill
//And the numberOfSectionsInTableView, numberOfRowsInSection and
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"cellForRowAtIndexPath:");
NSLog(@"Table View: %@",[tableView description]);
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"Hi";
// Configure the cell...
return cell;
}
я получаю в качестве вывода:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<List 0x6a78000> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableView.'
или просто список пустых ячеек, даже не «Привет» в качестве заголовка.
Этот код выглядит хорошо. Отладчик дает номер строки для ошибки? Хотя я не уверен в печати [tableView description]; у вас не должно быть необходимости в этом. (Этот метод не будет вызываться, если он недоступен) –
На данный момент я получаю исключение, поэтому NO NSLogs запускаются вообще :(. [Описание таблицыView] Я вставил, чтобы посмотреть, выбирает ли он правильный tableView для Кроме того, у меня есть подозрения, но на данный момент я получаю исключение. –
попробуйте установить свойство для сохранения вместо readonly. –