가 나는의 ViewController를 가지고 있고, 위임 UITableViewDelegate 및 UITableViewDataSource를 구현라고, 그래서 나는 방법에 따라 결코 : 나는 각 방법에 대한 중단 점을 설정 있는 tableview 위임 방법은
- (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
은 호출되지 않았지만 다른 두 메소드를 호출 할 수 있습니다. 그래서 뭐가 문제 야? 고맙습니다.
갱신 :
내가 IB에의 소유자를 제출 datasoucre 및 대리자를 연결,하지만 문제를 해결할 수 없습니다.
IB를 사용하고 있습니까? dataSource를 연결하고 IB의 속성을 위임 했습니까? 아니면 사용하지 않을 경우 코드에서 위임을 수행 했습니까? –
numberOfRowsInSection 메서드의 배열 수가 0보다 큰지 확인하십시오. –
네, 맞습니다. 내 질문에 대답하면 ... 동의합니다. – Gaojian922188