I want to refresh UITableView in UITabBarController - iphone

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!

Related

Adding Navigation Controller to existing UITableView

I'm new to both Objective-C and the iPhone SDK in general, so please bear with the noob question.
I've successfully implemented a table view with an array for the title, subtitle and cell icon and it's working out great. What I'd like to do is load a PDF file depending on which cell is selected and I understand that a Web View seems to be the best option?
I've hit a block, I can't add a navigation controller to the existing table view in the xib file (I started as a single view application) and everything that I'm reading around the interwebs is suggesting starting out in a different way. Either I'm doing something completely wrong or I've missed something entirely.
So is there anyway that I can implement this Navigation Controller and Web View with what I currently have or am I going to have to start again, copying and pasting various bits of code?
Any help appreciated.
Cheers.
Matt.
If you have a XIB file that represents a UITableView, then what you should be able to do is:
1) When presenting your UITableView:
UITableViewController *tableViewCon = ...; // Load it from the XIB file
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:tableViewCon];
// Present the navCon, however you're currently presenting your table view
2) In your UITableView, when a cell is pressed:
WebView *webView = ...; // Create the web view, and also load a URL
[self.navigationController pushViewController:webView animated:YES];
I think you need to rewrite your app. You cannot add navigation view to table view. The right pattern for your task is to start with navigation view controller as a root of your app and define your table view controller as a root controller for the navigation controller. Then, when the user selects some row in the table you should push a web view to your navigation controller.
refer for the UINavigationViewController class reference.

TableView is not showing data?

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

problem on reload tableview on tabbar project with sqlite

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];

Updating the TableView inside one of the bars in UITabBarViewController when something happens inside the other bar

I have a two tabbed application. The first tab is a NavigationController that has a few TableViewControllers in it. The second tab is also a NavigationController that has a TableViewController in it.
What I'm trying to achieve is: When someone clicks on a button in the TableView inside first tab, I want to add the the clicked row to the TableView inside the second bar.
I'm already saving the information when it is clicked to NSUserDefaults. When I quit the app and restart, the second bar shows the updated info. But it doesn't show the updated rows if I switch to it while the application is running.
How can I make the second bar reload/update dynamically with the updated rows when someone does sth in the first bar?
I've called [self.navigationController parentViewController] successfully to get the tabBarViewController, which is the highest level, when the the tableview in the first bar changes. How can I get to the TableView inside the NavigatinController inside the second tab from there to have it update itself? Or should I be doing this another way?
Thanks.
i think you can call reloadData in second bar's view controller function
-(void) viewWillAppear:(BOOL)animated
{
[tableView reloadData];
}
You could call the reloadData method on the UITableView within that TableViewController. Honestly, I think you should be using CoreData but I don't know enough of the structure of your data so... try that?

Only showing View after second Push on iPhone

I'm having an annoying problem, that may have a simple answer!
I have a ViewController (which contains a TableView Controller and Header View) which I am pushing on to a Navigation Controller - When I push it on the first time after launching, I get a blank view. When I click the Back button to pop it, it appears fine from then on until I re-launch the app.
Does anyone know an "obvious" reason why this would happen?
BTW- following the code in Debug, it appears to be doing all the correct things.. loading the ViewController variables if nil, etc. before the first view.
Thanks!
did you reload the table after data are loaded ?
[tableView reloadData];