У меня есть viewcontroller, и я реализую делегат UITableViewDelegate и UITableViewDataSource, поэтому у меня есть следующий метод:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [_nameArray count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 50;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"name";
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *TableIdentifier = @"TableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TableIdentifier]autorelease];
}
UILabel *nameLabel = [[UILabel alloc] init];
nameLabel.textAlignment = UITextAlignmentLeft;
nameLabel.text = @"100";
nameLabel.backgroundColor = [UIColor blackColor];
nameLabel.textColor = [UIColor yellowColor];
[cell.contentView addSubview:nameLabel];
[nameLabel release];
return cell;
}
Я установил точку останова для каждого метода, я могу найти
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
и
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
никогда не вызывается, но могут быть вызваны два других метода.так в чем проблема?спасибо.
обновление:
Я подключил datasoucre и делегировал владельцу файла в IB, но не могу решить проблему.