簡體   English   中英

如何使TableView在iOS中已加載的數據下可滾動

[英]How to make the TableView scrollable with already loaded data in iOS

我能夠從一個寧靜的Web服務中獲取數據列表。 目的是在iPhone應用程序中以行的形式顯示相同內容。

我可以在渲染視圖時用數據調出表。 但是我無法向下滾動以查看所有結果。

我是否需要在View Controller中實現任何方法?

我還可以為每一行添加詳細信息披露按鈕。 要對顯示按鈕進行觸地得分操作,我需要在View Controller中實現哪種方法?

參考: http : //developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/c/econst/UITableViewCellAccessoryDe​​tailDisclosureButton

請提出建議。

編輯:

這是如何在一行中添加UI按鈕的代碼片段:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

}

聽起來您正在同步地從Web服務加載數據,所以UI線程將被阻塞,直到完成為止,並且您將無法滾動表格視圖。 使用NSOperationQueueNSOperation ,GCD, NSURLConnection和一個委托,或類似AFNetworking的庫來異步加載數據。

至於公開按鈕,請參閱UITableViewDelegate 的文檔 具體來說,您對-tableView:accessoryButtonTappedForRowWithIndexPath:感興趣。

你需要這個:

[tableView beginUpdates];
[tableView insertRowsAtIndexPaths:*arrayOfIndexPaths* withRowAnimation:*rowAnimation*];
[tableView endUpdates];

暫無
暫無

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

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