i have a project with 3 tabs, first tab have tableview with navigation, i insert data in my second tab to database, when i switch back to first tab, there is not changing,
i connect to sqlite on viewDidAppear part,and put my data in this part but there is not changing result.
thanks for help
On viewDidAppear, after connecting with your database, you need to reload the table view. This will call all the table view data source functions again, such as cellForRowAtIndexPath.
[tableView reloadData];
Related
I have place this question before on following link with code & screenshot.
TableView is not loading data?
Now I came to know my tableview is loading data in tableview cell but not showing/displaying it. I have one Model View Controller in my project. The ModelView controller get called from Mapviewcontroller screen through Search Button. After resigning the Model view controller I can see the data in tableview. (It means when I move to next controller and back to previous tableview.. my tableview shows data in it.)
Here I my data get visible in tableview only after resigning the modelview controller.....
Everything works fine. I just want to know how should I display the tableview data as soon as web-service get called on first screen itself???
Put [_tableView reloadData]; at the end of the method that calls the web-service, or the one that populates the markers array.
If you are manipulating table data in an asynchronous Block,
pass a reference of the tableview to the method implementing the block, and remember to call
[tableview reloadData];
within the block, and not out outside
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 refreshes the tableview so I tried using it.
Are you sure your tableView outlet is linked correctly to your tableView property in Interface Builder ?
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.
I am using UITabBarController and I am setting some controllers in it ,when i tab to different controllers it works fine,But If iam inserting data in database and tab to second controller ,it dnt show the data except restarting the application.I think tabbar loads all controllers ,so i want to refresh my TableView so that I can view added data
any suggestions?
#Ali try reloading data in the tableView.....try this [self.tableView reloadData]; when you come back to your view where u want to display the data in the tableView i.e the view which contain UITableView
Hope this may help u!
hey, when my application loads i have a table view which shows data present in my database. On clicking the add button it goes to another view and the data inserted is updated in the database. Now how do i load this updated data when i return from this view to the first view.
Which method do i need to call? ViewDidAppear? or ViewWillAppear?
and how do i reset the entire table view n reload the data?
In viewWillAppear: call [self.tableView reloadData].
You can update the rows yourself by calling
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
This will give you the option to have the new row(s) appear in the tableview animated
http://developer.apple.com/iphone/library/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/insertRowsAtIndexPaths:withRowAnimation:
I am trying to update a list in a tableview controller. In viewWillAppear in that particular tableview controller, the tableView is setup with the code:
[self.tableView reloadData];
I am trying to do this refresh from an other Class (DetailViewController), which refers to another view controller.
In a method in DetailViewController I want to reload the data in JobsViewController, but can't do it. I can envision the below code working, but something is still missing. Can anyone please shed some light on this?
[JobsViewController.tableView reloadData];
Did you also change your data source? reloadData does only reload the cells. It doesn't take care of actually updating the underlying datasource. E.g. if you read data from an array in tableView:cellForRowAtIndexPath:, your have to change the array values befor calling reloadData.