Is it possible to redraw the whole view.
I need it to complete my language settings. The problem is that the language only changes after the views there drawn again. Like you go out of settings and then go in again, then the language is changed. But the moment you save everything, the language stays the same.
So how should i redraw my views, or by best the whole app, after the language change was found?
Force a Redraw With setNeedsDisplaysetNeedsDisplay() forces a redraw of a particular view. Because you should never call draw(_ rect: CGRect) directly, you can think of setNeedsDisplay() as a method of asking UIKit for a redraw.
setNeedsDisplay()Marks the receiver's entire bounds rectangle as needing to be redrawn.
The update cycle is the point at which control returns to the main run loop after the app finishes running all your event handling code. It's at this point that the system begins updating layout, display, and constraints.
In ARC:
- (void)setLanguage:(LanguageType)languageType
{
_language = languageType;
//TODO:your settings
[_theWholeView setNeedsDisplay];
}
If that can not work , there is a very troublesome solution , it can reload the whole view.
You can code like this: In the view.h , you need creat a delegate. @protocol WholeViewDelegate
- (void)reloadData;
@end
In the view.m
- (void)setLanguage:(LanguageType)languageType
{
_language = languageType;
//TODO:your settings
[_delegate reloadData];
}
In the controller you need to implement the delegate In the controller.m
- (void)reloadData
{
if(_wholeView)
{
[_wholeView removeFromSuperview];
}
// in the wholeView init method you should refresh your data
_wholeView = [[WholeView alloc] init];
self.view addSubview:_wholeView
}
Yes. Call [UIView setNeedsDisplay]
(reference).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With