iOS tableview data change - iphone

i've a method that populate a UITableView without problem.
if i go to setting page, change some settings and come back to my rootview i call the method with new settings but my UITableView display always the last values.
Any help?

[self.tableview reloadData];

Related

Issue in reloading tableView(SplitViewController) in ios

In my app, am using splitViewController concept for my contacts page.
In my rootViewController(ContactTableView_iPad.m) i want to reload my tableview on the click of filter button. But eventhough i have given the code
[self.tableView reloadData]
my tableView is not getting reloaded.
i even tried few other codes in order to reload my tableView. I have given my entire code in the following link.
Click here to view my code

How do I maintain the UITableView selected row when returning from a UINavigationController child screen?

I have a UITableView of customers where a row/customer is selected. The user can then push another view on the UINavigationController stack to add a new customer. When I pop the child screen and return to the UITableView the previously selected row is no longer selected.
I can re-select the row in viewDidAppear() but it looks bad as you can see the deselect and the select. Is there a way to maintain the selected row when returning from the child screen?
I assume you are using a table view controller, as otherwise it is your responsibility to write this behaviour anyway. In a table view controller, though, it's easy. Just add in viewDidLoad:
self.clearsSelectionOnViewWillAppear = NO;
That will keep the row selected, unless you manually deselect the row or the user selects another row on the table.
If you select it in viewWillAppear:, it should get selected without the user seeing it. Would that solve your problem?
You need to call:
[tableView deselectRowAtIndexPath:indexPath animated:YES];
This is found in the didSelectRowAtIndexPath delegate method for a UITableView.
By default, a selected row gets deselected (with animation) when you return to that VC.
So, if you push a DetailViewController, the cell stays selected until you return to the RootViewController and then gets deselected automatically.
I used to have such a problem too. Make sure to always call the superclass's implementation of methods such as viewWillAppear, viewWillDisappear etc.
Also, do not call deselectRowAtIndexPath: manually.
This is possible :
Only in once case: If you have the static content in TAbleView,
just reload the TableView in ViewDidLoad only, not in View will Appear.
whereas make sure, you don't allow table to reload anywhere in same class in any method. Then you can achieve what you want.
The cell get deselect because of reload the TAbleView.
But for Dynamic content, you need to use the delegate method:
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition;
In this you need to pass the indexPath which you want to show selected with the scrollPostion same as tableviewposition.
You cannot have a tableViewCell selected all the time. It gets back to normal once it serves its purpose. I think you meant highlighted or appear to be selected, and I am answering the question based on that.
Get the row that was selected at the cellForRowAtIndexPath. When you pop your navigation controller and come back to the tableView, go the the cellForRowAtIndexPath and have that cell highlighted (You can use any UIColor as you wish) - there is no specific way to highlight stuff - use your imagination - Default highlight style is Blue, while the text is White.
How is this done ?
Find selected row in cellForRowAtIndexPath
Store is in an external variable / or NSUserDefaults and you can also use NSUserDefaultsto communicate between screen to find out if item was popped from that screen.
[tableView reloadData] in viewWillAppear
Check for NSUserDefaults value in cellForRowAtIndexPath and modify that cell with cell.backgroundColor or something.
Without some code, I can just give an advice : stop using [tableView reloadData], use [tableView beginUpdates], [tableView endUpdates] and – insertRowsAtIndexPaths:withRowAnimation: and – reloadRowsAtIndexPaths:withRowAnimation:. Things should work as expected.

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?

I want to refresh UITableView in UITabBarController

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!

iphone reload table data

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.