开发者

How Can I hide an info button from a subview?

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

From mainViewController, under viewDidLoad, I'm inserting subview A. Here I notice that the info button is in front of the subview A, which is fine.

The problem comes that when pressing any buttons that are located within subview A's nib file, in which they add new subviews, the info button remains on front.

So, how can I add these later sub开发者_如何学编程views on front of all parent view stacks, so the info button does not appear? or how can I hide the info button?


If I understand correctly, your mainViewController's view has two superviews: subView A and infoButton. You'd like to add subviews to subviewA that appear over the infoButton view?

The simple answer is that you can't make subviews of subviewA appear over the infoButton view. If you think of the view hierarchy as a tree, the renderer draws the views in a depth-first way. This means it draws subviewA, and all of subviewA's subviews (and so on) before it considers the infoButton view. If you want a view to appear over the infoButton view you need to add it as a sibling of infoButton after infoButton in the main view's subview list.

If you'd like to hide the infoButton, you can simply set the hidden property to YES, and then set it to NO when you want the infoButton view to reappear, of course.

Depending on what you're doing with subviewA, you might consider using a modal view controller or a navigation controller to manage the views that you add when the user interacts with subviewA.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜