Question

In the iPad you can change the appearance of the app in a view which is modally pushed. But after selecting a theme and dismissing the view the appearance does not change. if I push an other view full-screen, the view is updated.

How can I force to update/refresh/repaint the appearance?

EDIT

I tried playing setNeedsDisplay everywhere, but the app does not respond directly. As the reference said, the view is marked to be redrawn as soon as the loop restarts.

And because the view is already loaded with an other appearance behind the modally pushed appearance changer view, it is not reloaded.

Était-ce utile?

La solution

I quick-fixed it.

I just start with a full-screen modal view and after I changed the theme I dismiss the view, so the views behind it will be updated.

If some one has a better solution I really like to hear about it.

Autres conseils

[view setNeedsDisplay] is typically used to tell the view it needs to be redrawn.

[view setNeedsLayout] is the same for -layoutSubviews

See:

I had more or less the same issue changing the appearance of UISliders. Using [self.view setNeedsDisplay] had no effect.

With the line of code below the appearance of the sliders did not change as expected, but only afterwards if another view were loaded and dismissed.

[[UISlider appearance] setMinimumTrackTintColor:[UIColor greenColor]]; 

Creating IBOutlets for each slider and setting tintcolor as below had the desired effect and changes took place immediately.

[volumeSlider setMinimumTrackTintColor:[UIColor greenColor]];
[brightnessSlider setMinimumTrackTintColor:[UIColor greenColor]];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top