Я создаю приложение, которое использует TabBarController для отображения нескольких других представлений. В одном из этих представлений я использую контроллер навигации для навигации по некоторым табличным данным. Когда пользователь нажимает на эту вкладку, я загружаю в NavigationController, который в свою очередь загружает TableView, который я использую. Проблема в том, что я получаю следующую ошибку при загрузке контроллера TableView:
-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x6b37b10
Я везде читал, что этот тип ошибки обычно происходит из-за неправильного соединения в IB или что класс неверен в контроллере представления. Вот мой код и скриншоты IB, чтобы помочь отладить это для меня.
Заранее спасибо!
Ошибка, которую я получаю
Соединения TableView в IB
Класс владельца файла
Мой интерфейсный файл
@interface FAQListViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
// Dictionary that will hold the FAQ Key/Values
NSMutableArray *arrFAQData;
}
Осуществление
@implementation FAQListViewController
// Implementation for UITableView numberOfRowsInSection protocol
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [arrFAQData count];
}
// Implementation for UITableView cellForRowAtIndexPath protocol
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// See if we have any cells available for reuse
UITableViewCell *objCell = [tableView dequeueReusableCellWithIdentifier:@"FAQCell"];
if (objCell == nil) {
// No reusable cell exists, so let's create a new one
objCell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: @"FAQCell"];
}
// Give it data
NSDictionary *objRow = [arrFAQData objectAtIndex: [indexPath row]];
objCell.textLabel.text = [objRow valueForKey:@"Title"];
// Return the created cell
return objCell;
}
// Selection Event Handler
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Get the value for the selected key
NSDictionary *dictRow = [arrFAQData objectAtIndex:[indexPath row]];
NSString *strURL = [dictRow valueForKey: @"URL"];
// Alert result
UIAlertView *objAlert;
objAlert = [[UIAlertView alloc] initWithTitle:@"Alert" message: strURL delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
// Release created objects
[objAlert show];
[objAlert release];
// Deselect row
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)viewDidLoad {
// Pull in FAQ from Plist
NSString *strFAQPlist = [[NSBundle mainBundle] pathForResource:@"FAQData" ofType:@"plist"];
arrFAQData = [[NSMutableArray alloc] initWithContentsOfFile: strFAQPlist];
[super viewDidLoad];
}
- (void)dealloc {
[arrFAQData release];
[super dealloc];
}