2012-07-27 57 views
0

我從json獲取數據。它工作正常,但問題是數據不顯示在tableView中。數據沒有顯示在iphone tableView

我檢查了使用NSLog分配給單元格的值,但單元格不顯示任何數據。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 

// Customize the number of rows in the table view. 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    int count = [surveyList count]; 
    NSLog(@"These are rows %d",count); 
    return [surveyList count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
    } 
    ObjectData *data = [surveyList objectAtIndex:indexPath.row]; 
    NSString *testingClient = data.survey_title; 
    NSLog(testingClient); 
    NSString *cellText = testingClient; 
    return cell; 
} 
+0

確保分配委託給你的表視圖, – DivineDesert 2012-07-27 04:25:03

+0

是的,我已經指派delagate有人告訴tableviewrealod數據創建類似的問題,但我還沒有重新加載任何東西 – user1553768 2012-07-27 04:28:18

回答

1

你是否錯過了這個?

[[cell textLabel] setText:testingClient]; 

你是不是沒有它分配任何文本的單元格。

+0

我也給了這個 – user1553768 2012-07-27 04:47:15

1

您應該指定該文本單元的標籤。

cell.textLabel.text = testingClient; 
+0

是的,我已經做了這樣也 – user1553768 2012-07-27 04:39:33

+0

第一次嘗試加載一些虛擬數據到你的桌子..確保你的桌子被填充並且工作正常。找到一個教程做一個tableView – Zaraki 2012-07-27 04:44:50