Skip to content
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 reload the settings menu #92

Closed
alamodey opened this issue Mar 7, 2021 · 5 comments
Closed

How to reload the settings menu #92

alamodey opened this issue Mar 7, 2021 · 5 comments
Labels

Comments

@alamodey
Copy link

alamodey commented Mar 7, 2021

Hi, I need to be able to programatically reload the settings view for two reasons:

  • some users are confused after they upgrade to premium that the menu still has options disabled as though they are not premium users
  • I have using this NavigationRow(text: "CellStyle", detailText: .value2(".value2")) and after a user selects a new option for .value2 I want my settings menu to display the new value instead of the initial one loaded at app launch

Is it possible to reload the menu? Thanks.

@bcylin
Copy link
Owner

bcylin commented Mar 8, 2021

I suppose by "reload the menu", it means reloading the table view?

Updating tableContent reloads the table view so you can recreate table contents whenever the setting's value changes.

class ViewController: QuickTableViewController {
    private var settingsValue = SettingsValue() {
        didSet {
            tableContent = recreateTableContent()
        }
    }
}

extension ViewController: AnotherViewControllerDelegate {
    func anotherViewController(_ controller: AnotherViewController, didUpdateSettingsValue value: SettingsValue) {
        settingsValue = value
    }
}

@alamodey
Copy link
Author

I am a bit confused by this, are you able to update your code base so it automatically reloads, or at least gives the option to?

Alternatively I tried to just re-create the table in viewDidAppear - it works, except there's a bit of lag so you can see the .value2 text change from the previous value to the new one.

@bcylin
Copy link
Owner

bcylin commented Mar 10, 2021

If you recreate the table content in viewDidAppear(_:), the table view reloads after the view appears.

Basically recreating the tableContent reloads the table view. Where and when to update the tableContent depends on your business logic.

@alamodey
Copy link
Author

Ah thanks for pointing that out. I just re-drew the table in viewWillAppear instead and it works fine. 🙂

@stale
Copy link

stale bot commented Mar 25, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 25, 2021
@stale stale bot closed this as completed Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants