2010-11-24 5 views
1

얘들 아 내가 보여줄 때 talbeview 빈 행 많이 있습니다 ... 내가 행의 수는 [NSArray를의 COUNT]테이블보기 행

내가 정확하게 일치 표시 할 수 있습니다 방법을 잘

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

표시 할 올바른 행 수를 반환하십시오.

+1

일부 코드는 도움을 주시기 바랍니다. 당신의 배열이 준비한 tableView 데이터 소스 메소드와 메소드를 넣으십시오. – Ishu

+0

- (NSInteger)를 tableView (jQuery과 *)를 tableView numberOfRowsInSection (NSInteger) 섹션 {\t \t 창 [quiz.questions 카운트]; } [questions count]가 5를 반환하지만 tableView는 빈 행이 추가로 5 개 이상 표시됩니다 ... 어떻게 표시합니까? – Yongzhi

답변

2

테이블 footerView를 아무 것도 렌더링하지 않는 뷰 (nil이 아님)로 설정합니다.

tableView.tableFooterView = [[UIView allocate] init] autorelease];

+0

도와 줘서 고마워! – Yongzhi

0

올바른 장소를 갖고 있으며 실제로 이미 답변을 가지고 있습니다. 여기 코드입니다 :

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [yourDataArrayName count]; 
} 

있는 tableView에 대한 대체 테이블의 실제 이름과 에 대한 배열의 실제 이름 yourDataArrayName, 분명히.

+0

내 말은 ...이 메서드는 5를 반환하지만 테이블 뷰에는 5 개 이상의 행이 표시되고 추가 행은 비어 있음을 나타냅니다. 이제이 테이블 뷰에서 정확히 5 개의 행을 표시합니다. – Yongzhi

+0

5 개 항목이있는 경우 tableview는 5 행만 그릴 것이다. 빈 값/사전이 포함 된 배열 요소를 가지고 있지 않습니까?반환 선에 중단 점을 넣고 앱 실행이 일시 중지되면 "print [yourArrayName count]"(따옴표 제외)를 입력하여 실제로 5가 있는지 확인하십시오. –

+0

배열의 요소는 5 개 뿐이므로 footerview입니다 물건 ... 어쨌든 당신의 도움을 주셔서 감사합니다 :) – Yongzhi

0

당신은 적절한 장소를 가지며 실제로 이미 답을 갖고 있습니다. .... 가 도움이 될 수 있습니다 시도

  • (NSInteger)있는 tableView : 여기 코드입니다 (jQuery과 *)있는 tableView numberOfRowsInSection : (NSInteger) 섹션 { 반환 totalRows; } totalRows는 = (그렇게 원하는 어떤 행.)

  • (있는 UITableViewCell *)있는 tableView : (jQuery과 *)있는 tableView cellForRowAtIndexPath : (NSIndexPath *) indexPath {

    NSString * CellIdentifier = [NSString stringWithFormat : @ "% i % i", indexPath.row, indexPath.section]; UITableViewCell * cell = [self.tableView dequeueReusableCellWithIdentifier : CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle : UITableViewCellStyleDefault reuseIdentifier : CellIdentifier] autorelease]; cell.accessoryType = UITableViewCellAccessoryNone; cell.accessoryType = UITableViewCellAccessoryNone; cell.highlighted = 예 }