Can a view manager manage more than 1 nib based view?

I have a VC controlling the content screen, which has 2 modes; normal mode and editing mode.

Can I create one VC with 2 views, each of which will be separated from individual knives?

In many situations on the iphone, you have a VC that controls the associated presentation. Then, at the click of a button or other event, a new VC is loaded, and its presentation becomes a top-level view, etc.

But in this situation, I have 2 modes that I want to use the same VC, because they are closely related. So I want a VC that can change / view 2 views.

Like here: How to load a UIView using a nib file created using Interface Builder

I found that I can load VC with the view associated with it, and then load another view from another tip and make this new view active.

NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"EditMode" owner:self options:nil];
UIView *theEditView = [nibObjects objectAtIndex:0];
self.editView = theEditView;
[self.view addSubview:theEditView];

The secondary tip has outputs connected to the VC as a primary tip. When a new tip is loaded, all sockets are plugged in well and everything works well. Unfortunately, when this editing view is then deleted, there seems to be no graceful way to plug in the sockets again into mode (normal mode) from the original tip. Setting up Nib loading and unloading seems like just one thing.

So, if you want to have a VC that swaps to / from 2 views without creating a new VC, what are the options?

1) You can do everything in code, but I want to use nib because it makes it easier to create a user interface.

2) 1 VC / , UIView .

3) , . , , .

4) , 1:1 VC . , , VC, .

, 4), , , , , VC, . NSTimer . - , VC 2 .

+3
1

nib IBOutlet, editView.

@interface TestViewController : UIViewController {
    IBOutlet UIView *editView;
}
@end

alt text

[self.view addSubview: theEditView]; .

0

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


All Articles