I built an app that displays a tableview. If the user tap an entry it goes to the detailed screen. In the detail screen, I have a button to delete this entry. I delete the record from the datasource and go back to the previous screen (the one with table view). I can create a refresh button and call the reloadData method, which is working fine. However, I would like to eliminate refresh button and it refresh the data automatically. Like in the new app in iOS 5 called reminders. I can tap the task and it goes to the details screen. If I delete the task in the details screen, it will go back to the previous screen and the records has been removed from the display automatically.
Any idea on how to accomplish this?
Thanks.
whenever you enter the tableview from detailview override viewwillappear delegate
-(void)ViewWillAppear
{
[tableview reloadData];
}
Related
I have a view with the list of entities pulled from a remote source (via web-service). App crashes, if back button is pressed (view with tableview disappears) while the entities are being loaded on to the table view.
If any keyboard appeared, resign the keyboard.
What about using NSOperation to retrieve the data from your Web Service, and cancel it if the user press the back button?
http://nshipster.com/nsoperation/
Another Option would be to check the view in the completion handler (when your data is ready)
you have to stop the remote service call in viewWillDisappear (or) use IgnoringInteractionEvents up to that page load.
I've a tableView which appear modally from another controller, in this table user select a row then, clicking the row, tableView closes and user get back to previous controller with self.dismissViewControllerAnimated(true, completion: nil) in UITableView's didSelectRowAtIndexPath.
Strange thing is that, after user's tap, self.dismissViewControllerAnimated locks app for some seconds or until user click the screen for a second time, then app proceed running...
Here's the source code.
How can I solve this issue?
NOTE FOR MODERATORS: It's not a duplicated of UIViewController dismissViewControllerAnimated: completion: causes app to freeze, there trouble was caused from an external framework!
Your answer is, that you made a common mistake. You do NOT call didSelectRowAtIndexPath but didDeselectRowAtIndexPath
That means, your "lock" of the app is just the expected behavior of didDeselect...:
This method is only called if there is an existing selection when the user tries to select a different row. The delegate is sent this method for the previously selected row. You can use UITableViewCellSelectionStyleNone to disable the appearance of the cell highlight on touch-down.
In my app, there are tabs. I have one tableviewcontroller that contains messages and I have implemented pull to refresh so that works fine. However, if the user goes from the message tab to another tab and then back to the message tab, the uitableview doesn't reload and the user has to pull to refresh. I have thought of putting [self.tableview reloadData] or [self loadObjects] (i am using Parse) in viewDidLoad/viewWilAppear, but that doesn't seem to work...it's because they are only called when the view controller is initially visited right? So I'm wondering as to where I should put that code so that the table view can be reloaded every time the view controller is revisited?
viewWillAppear and viewDidAppear are both called every time the view controller appears. If you call reloadData in one of those methods then it will refresh the table view.
I think your problem is you aren't updating your data source. You will need to make another call to Parse otherwise your table view will just reload with the same data.
I don't think that this behavior is desirable. I suggest you tu wait for a reasonable timeout before updating data, or your user will experience lags and high network usage.
However to do that, you should set a delegate that fires when the corresponding view is loaded (take a look here how to get the event that switch tab menu on iphone ) and then call
[yourTableView reloadData]
inside didSelectViewController
In my project I have two view controllers one that lists all the core data stored in a table view and a second that allows the user to input data to be stored. However when I click the back button on the navigation controller on the second it fails to refresh the tableView.
I have tried [self.tableView reloadData] in the viewDidLoad as a bit of a long shot but no joy.
How would i go about refreshing the data when the user clicks back?
Many thanks
Danny
The shortest route would be to move [self.tableView reloadData] from viewDidLoad to viewDidAppear but I would suggest using a delegate or callback so that it only reloads when necessary.
In my app I load data from URL, parsing it, and put in TableView. When user push on some row - initializing method in which pass element's ID and again load data from URL, parsing and reloading TableView. This continues until user saw last element, when he push on it - opens new ViewController (DetailViewController for example). It will be good if user can go back and see in reverse it all. With DetailView all clear - just organized data back with segue, and reload scene.
But the my question is - How to make that when user push Back button on Tableview, TableView reloading in right reverse order?
In this case navigationControl is your friend. Build different views for any click, then instantiate and call the pushViewController with navigationControl. The navigationControl will handle the back button it self.