How can I add a view from subviews on top of my supervisor?

I have mainViewController and inside its nib file. I added an info button in which the action should flip between two subviews, subview A and subview B.

From mainViewController, under viewDidLoad, I insert subview A. Here I notice that the info button is in front of subview A, and this is normal.

The problem is that when you press any buttons located in the nib sub-file in which they add new routines, the information button remains on the front panel.

So, how can I add these later subviews in front of all the stacks of the parent view, so the info button does not appear? or how to hide the info button?

+3
source share
2 answers

You can put subview infront of everything else by calling

[view bringSubviewToFront:subview];

You can hide the button (or any other user interface element) by calling it with the setHidden function as follows:

[button setHidden:YES];
+6
source

always an application can contain only one window at a time. so this is the best way.

UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
[mainWindow addSubview:yourView]; 
+1
source

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


All Articles