UITableView reload data

后端 未结 7 1325
鱼传尺愫
鱼传尺愫 2020-12-01 00:27

i\'m making a navigation based application for iphone.

one of my view controllers looks like this:

@interface NewComputerViewController : UIViewContr         


        
相关标签:
7条回答
  • 2020-12-01 00:42

    [tableView reloadData]; where tableview is the name of your UITableView

    0 讨论(0)
  • 2020-12-01 00:44

    When even reloading...

    [tableView reloadData];
    

    will not reload the edited rows/cell, maybe the IBOutlet of tableView is not connected in XIB file?

    This could be one of the reasons.

    0 讨论(0)
  • 2020-12-01 00:52

    at the end of your function loadstuff reload the contents of ur table by writing the following code:

    [tableView reloadData];
    
    0 讨论(0)
  • 2020-12-01 01:01

    Very important is the fact, that you need to make sure, that the source of your tableview reflects your changes too.

    When you i.e. remove something, [tableView reloadData] won't do anything when you do not delete the item in your source first.

    I had this issue in following situation: I had a tableview which showed some files in my document folder. Then I wanted to delete some files and I deleted them in the documents-folder, but they still appear in my list. I tried [tableView reloadData] and all other suggested answers in this post, but there were still the files listed. When I closed the tableview and opened it again, then the list was fine. Why? Well, because I filled an NSArray with all my files -> this is my "source" for the tableView. So when I delete a file, I do not only need to delete the file in the documents-folder, I need to remove it from the array too. -> So I made an NSMutableArray to have the ability to remove it. Then call [tableView reloadData] and the list is fine. ;-)

    0 讨论(0)
  • 2020-12-01 01:02

    Try using [tableView reloadData]; (where tableView is the name of your instance variable)

    0 讨论(0)
  • 2020-12-01 01:03

    You can always use [tableView reloadData] method!

    But if you have some data stored locally and loading new stuff from some server then you can go for:

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

    And if you want to delete existing row you can use

    [tableView beginUpdates];
    [tableView deleteRowsAtIndexPaths:*arrayOfIndexPaths* withRowAnimation:*rowAnimation*];
    [tableView endUpdates];
    
    0 讨论(0)
提交回复
热议问题