开发者

Reload data in UItableview using a button

I want to add a refresh button in UINavigationBar that refreshes the entire table contents. Nothing happens when i click on the refresh button. I searched google and found that reloadData method refresh开发者_如何转开发es the tableview so I tried using it.


  1. Are you sure your tableView outlet is linked correctly to your tableView property in Interface Builder ?
  2. Is your internal datasource `refreshed' before you call reloadData?


-[UITableView reloadData] tells the table view to request again from you the number of rows in the table, and the cells at each section and row. It's up to you to update your internal data structures as appropriate. So in this case, your IBAction should call your own method to refetch the data from the server.

A few other notes:

  • Method names should have leading lowercase.
  • -initWithContentsOfURL: is blocking. This can hang your program for a long time. You should be using asynchronous fetching here (generally with NSURLConnection).


make sure you have the tableView outlet hooked up to the tableView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜