-
-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to ask InAppSettingsKit to reload the settings. #171
Comments
IASK automatically updates the views when the underlying NSUserDefaults are changed. This is done by observing the NSUserDefaults change notification. Or did I misunderstand your question? |
What happens if you're using a private implementation of IASKAbstractSettingsStore? Marking Would it be possible to detect settingStore changes and force-reload the existing views? |
Currently, automatic reloading is only implemented for NSUserDefaults. We'd gladly accept a pull request to generalize this for all stores. ;-) |
I am also looking for this feature. I need the Settings view to update itself even though the underlying NSUserDefaults have not changed, because I need to be able to update all the labels whenever the user choses a new user interface language. (Believe me that I have a reason why I am giving the user the option to change the user interface language, overriding the default behavior of the app taking the user interface language from the device language.) When the user choses a different interface language, than my settings view controller (which extends the IASKAppSettingsViewController) detects that, does its thing, and traces out to the console proof that NSLocalizedString() is now returning the messages localized into the selected language. At that point I am then wanting to update the Settings view itself so that it reloads all the text so it's all localized. I have tried all of the following, to no avail:
:-( Any tips? Thanks, |
Hi. How can I do that please ? Thks |
@neospirit Cyrille, when you change the NSUserDefaults in your fetch method, IASK should automatically update the view. |
If anyone's still interested, here's how you reload the settings after changes in custom settings store. InAppSettingsKit posts a notification when settings change - kIASKAppSettingChanged. To solve the issue, we subscribe to kIASKAppSettingChanged. I'm assuming that your class is inherited from IASKAppSettingsViewController.
IASKAppSettingsViewController:reload is private, so we expose it using a category. |
With Swift 3.0 I did something a little different because you cannot expose private functions using categories. In my case I just want to reload the settings in my custom cell views, which is specifically filtered out in the default handling of the NSNotification message. So I do: func settingsViewController(_ sender: IASKAppSettingsViewController!, buttonTappedFor specifier: IASKSpecifier!) {
...
UserDefaults.standard.synchronize()
// This is what is done in InAppSettingsKit to reload
sender.tableView.perform(#selector(UITableView.reloadData), with: nil, afterDelay: 0.5)
...
} |
I've got a resetToDefaults() method that overwrites all of the app's settings. I don't see any means in InAppSettingsKit's API to ask it to reload the settings. Can this be added? Am I missing something?
The text was updated successfully, but these errors were encountered: