2012-11-21 92 views
1

解析本地XML文件時,我可以使用NSLog在控制檯中看到數據。在模擬器中,只有普通表格視圖沒有從xml解析任何數據。我不明白哪裏錯過了它。爲什麼表視圖不顯示iphone中的任何數據

StoryBoard

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];  
    if(cell == nil){  
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];  

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 

    theLists = [app.listArray objectAtIndex:indexPath.row]; 
    cell.textLabel.text = theLists.title; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    return cell; 
} 
+1

請張貼代碼或現在你有足夠的聲譽,然後發佈圖片 –

+0

發佈一些代碼,你在哪裏傳遞您的數據的tableview。 – spider1983

+0

@sathya現在你可以發佈你的圖片,你想展示什麼。 – Debabrata

回答

0

我得到了答案終於在這裏我沒有正確使用相應的控制器連接的tableview控制器類。我跟着鏈接Trouble making connections with story board

最後它顯示在表格視圖中的數據。 希望這個答案可能會幫助其他人。感謝所有在這篇文章中給出建議的人。

2

我想你不重裝表視圖。 完成解析後,只需重新加載您的表格視圖。

[reload tablename];

然後檢查你的表視圖代表呼籲或不經過這種方法。 我認爲這會對你有所幫助。

快樂編碼。

+0

我已經在這裏的代碼重新加載它 - (無效)viewDidLoad中 { [超級viewDidLoad中] 應用程式= [[UIApplication的sharedApplication]委託]; [self.tableView reloadData]; } – sathya

0

看來你在DidLoad.But正在重新加載解析和XML獲取數據後,你必須重新裝入TableView中的數據。

[yourtableView reloadData]; 

在做事情之前,確保您已經設置了委託和數據源。

0

我認爲雙方有兩個原因預期:

1-可能部分和行數的數量沒有設置正確的值。

2-可能需要重新加載表格視圖數據。

請檢查這兩種方法:

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

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

return 5; // or any number you want 

} 
+0

我使用表格視圖返回值這樣的回報[app.listArray計數]我也嘗試過直接給元素的個數如你所說的回報5都可能表明我沒有改變 – sathya

+0

我想確切的視頻,下面我列出嘗試這個XML解析,請檢查它。第一部分http://www.youtube.com/watch?v=-PZlaDVsLBk&list=UUnwqFfbldaQUIcHneCjf1gQ&index=5&feature=plcp第二部分http://www.youtube.com/watch?v=7WpPgy2nbbI&list=UUnwqFfbldaQUIcHneCjf1gQ&index=3&feature=plcp部分-3 http://www.youtube.com/watch?v=9higZGafnD4&list=UUnwqFfbldaQUIcHneCjf1gQ&index=4&feature=plcp – sathya

0

想我要補充這一點,如果您有數據沒有顯示出來或加載麻煩。

確保您的tableview委託和數據源設置爲自我。

所以在視圖控制器的viewDidLoad()函數,請確保您添加

tableView.delegate = self 
tableView.dataSource = self 
相關問題