簡體   English   中英

cellForRowAtIndexPath只被調用一次

[英]cellForRowAtIndexPath is getting called only once

我不知道我做錯了什么,但表視圖的cellForRowAtIndexPath方法只被調用一次。

這是我的代碼:

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

     NSLog(@"--->%d",[collaboratoresdata count]);

    return [collaboratoresdata count];

}

當我的collaboratoresdata數組被填滿時,我正在調用[_collaboratortblView reloadData]來重新加載表視圖。

我在NSLog(@"--->%d",[collaboratoresdata count]);成功獲得3NSLog(@"--->%d",[collaboratoresdata count]); 但是cellForRowAtIndexPath只被調用一次。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    // add a placeholder cell while waiting on table data

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;


    NSLog(@"tableView:%d",[indexPath row]);// i am getting 0 here than after its not calling

    return cell;

}

檢查細胞的高度,我認為這是問題

please try to set height of cell manually(custom). So, if problem of cell height then it will be resolved. below method set cell height 30 pixels.

#pragma mark- TableView delegate Methods
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ 
return 30.0f;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM