Multi-Point Single View Controller?

I am trying to create a view controller that can be "painted", i.e. have multiple appearances or personalities, but use a single controller. Each view will have the same buttons, etc., but I would like to be able to load each nib file (skin) into the same view controller. I can create multiple nib files, but I don’t see how to connect buttons and actions. Is it possible to specify the same "file owner" for multiple nib files? (AS?).

Can this be done?

+8
iphone uiviewcontroller nib
source share
2 answers

It is quite possible. Just create new nib files, and in Interface Builder set the file owner to the class. Then you can connect your outlets and actions in the same way as before. From your code, simply specify the correct nib file in the initWithNibName: method.

If only the changes are indirect, you might be better off just making these changes to the code, but your proposed method will work just fine.

+8
source share

you can make it a lot easier if you literally copy and paste the view inside the nib file into the same nib file so that you have 2 separate views inside 1 nib file.

example pic

then you can swap between views when loading beer like this:

NSArray *temp = [[NSBundle mainBundle] loadNibNamed:@"Widget" owner:self options:nil]; Widget *w = [temp objectAtIndex:0]]; // or 1 or 2 etc to get the different views 

this will copy all your connections with buttons, etc., so you can just play with the copy without setting everything up again

0
source share

Source: https://habr.com/ru/post/650093/


All Articles