1

If your app supports multiple UI themes by having multiple nib files for it's view controllers, then when the user changes the theme through a settings menu in the app, what are your options for causing the running app's view controllers to reload their views with a different nib file?

I'm already aware of the basics - i.e. that you can load a different nib file conditionally based on a setting stored somewhere like NSUserDefaults. But after that, at the moment the user (in the app) changes the theme setting, what are my choices for having the change take effect?

I imagine I could tell the user that the theme change will take effect the next time he starts the app, but what about in real-time? Can I force the app to reload views similar to the way it does when a low memory condition occurs?

1 Answer 1

1

I think you may be approaching this in the wrong way.

If you are simply changing colours and images depending on the theme I would consider creating one xib and changing the colours and images in code.

The problem with multiple xibs is you increase the amount of things you need to maintain when really the only variables are likely to be properties.

Changing properties is much simpler and you could also introduce a new class to manage themes

e.g.

// psuedo class/code
Theme *theme = [[Theme alloc] initWithStyle:ThemeWarm];

self.view.backgroundColor = theme.backgroundColor;
self.view.logo            = theme.logo;
Sign up to request clarification or add additional context in comments.

1 Comment

Great suggestion, I hadn't thought of this. However the differences between themes that i had in mind are more than that- e.g. labels and buttons differing in size and frames, as well as additional images in one theme that are not in the other. So i'm leaning towards multiple-nibs approach still.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.