Я настраиваю простой табличный вид для своего приложения, но похоже, что код не работает в XCode 6, он работает в XCode 5. Я получаю ошибку SIGABRT после загрузки экрана запуска :UITableViewCell TitleLabel - непризнанная ошибка выбора
2014-12-19 13: 44: 06,584 TableTest Таблица [763: 165564] - [UITableViewCell TitleLabel]: непризнанные селектор направлен например 0x14555e30 2014-12-19 13: 44: 06,586 TableTest Таблица [ 763: 165564] * Завершение приложения из-за неперехваченного исключения «NSInvalidArgumentException», причина: '- [UITableViewCell TitleLabel]: непризнанный селектор, отправленный в экземпляр 0x14555e30' * Первый стек вызовов броска : (0x21a4f49f 0x2f205c8b 0x21a548b9 0x21a527d7 0x21984058 0x4b7c3 0x251d7787 0x251d784b 0x251ccfa1 0x24fe50df 0x24f0f24f 0x24937a0d 0x249333e5 0x2493326d 0x24932c51 0x24932a55 0x25173055 0x25172217 0x25173dfd 0x2517e209 0x281e00d1 0x21a15d7d 0x21a15041 0x21a13b7b 0x219613c1 0x219611d3 0x24f761bf 0x24f70fa1 0x4bbd1 0x2f785aaf) LibC++ abi.dylib: завершение с неперехваченного исключением типа NSException
Я следую учебник по GeekyLemon: https://www.youtube.com/watch?v=ITUI7fukRO8 и вот код используется:
Я вставил код здесь, но код также доступен по этой ссылке: http://www.geekylemon.com/xcode-tutorial-table-view-p1
Спасибо!
TableViewController.h:
@interface TableViewController : UITableViewController {
}
@property (nonatomic, strong) NSArray *Images;
@property (nonatomic, strong) NSArray *Title;
@property (nonatomic, strong) NSArray *Description;
@end
TableViewController.m @implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
_Title = @[@"Big Ben",
@"Colosseum",
@"Great Wall of China",
@"St Basil’s Cathedral",
@"Statue of Liberty",
@"Stonehenge",
@"Taj Mahal",
@"The Eiffel Tower",
@"Tower of Pisa",];
_Description = @[@"London, England",
@"Rome, Italy",
@"China",
@"Moscow, Russia",
@"Liberty Island, New York",
@"Wiltshire, England",
@"Agra, India",
@"Paris, France",
@"Pisa, Italy",];
_Images = @[@"BigBen.jpg",
@"Colosseum.jpg",
@"GreatWallOfChina.jpeg",
@"StBasils.jpg",
@"StatueOfLiberty.jpg",
@"Stonehenge.jpg",
@"TajMahal.jpg",
@"EiffelTower.jpg",
@"TowerOfPisa.jpg",];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return _Title.count;
}
@end
TableCell.h
@interface TableCell : UITableViewCell {
}
@property (strong, nonatomic) IBOutlet UILabel *TitleLabel;
@property (strong, nonatomic) IBOutlet UILabel *DescriptionLabel;
@property (strong, nonatomic) IBOutlet UIImageView *ThumbImage;
@end
TableViewController.m снова
#import "TableCell.h"
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TableCell";
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
int row = [indexPath row];
cell.TitleLabel.text = _Title[row];
cell.DescriptionLabel.text = _Description[row];
cell.ThumbImage.image = [UIImage imageNamed:_Images[row]];;
return cell;
}
если нет повторно используемой ячейки? как вы могли использовать ячейку? –
@WorldOfWarcraft Я новичок в XCode, поэтому я не уверен, что вы имеете в виду. В TableViewController.m есть строка, которая гласит: TableCell * cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier forIndexPath: indexPath]; Это вы имеете в виду? –
Вы получаете экземпляр 'UITableViewCell' вместо экземпляра' TableCell'. Удостоверьтесь, что вы зарегистрировали соответствующий класс ячейки в своем представлении таблицы. – rmaddy