Remote reloading a view
-
10-10-2019 - |
문제
I was wondering if there is a way to reload a view controller inside one tab from another tab. This is my scenario
- Tab controller has 2 or more tabs
- Tab 1 has a view controller which has views created based on some conditions
- Tab 2 is a settings page, where some app settings can be changed
- How can i reload content inside tab 1 when settings in tab 2 are changed?
IS there something like tab bar -> tab -> view controller -> reload viewDidLoad?
Thanks
해결책
The general way I solve this problem is by having a "Settings"-type object (Model) that is observed by my view controllers. In your case, you'd initialize it in your app delegate, pass it along to the view controllers for Tab 1 and Tab 2, which would then use KVO to observe it. You'd also directly modify it in Tab 2's view controller.
You could also use a NSNotifcation
to signal a change in the settings to any view controller that wants to observe it.
제휴하지 않습니다 StackOverflow