开发者

How do I change the UIView programmatically?

I have created View A and View B. My window has View A displayed on the screen. I also have a UIButton on View A. I want to switch from View A to View B when I click on the Button. I am not using any UIViewController. Is it possible to swi开发者_开发百科tch the views without using controller? I am calling buttonAction method on TOUCHUPINSIDE

The problem is that it doesn't do anything when I say

[ViewA removeFromSuperView];

What should I do now?


If viewB is not in the view hierarchy:

[[viewA superview] addSubview:viewB];

If viewB is in the view hierarchy:

[[viewA superview] bringSubviewToFront:viewB];

Once viewB is in the view hierarchy, then remove viewA:

[viewA removeFromSuperview];

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜