开发者

How to load a new view within a view controller when a uibutton is tapped

开发者 https://www.devze.com 2023-01-12 02:10 出处:网络
I\'m creating a tab-based app. I want one of the tabs to include the following: -Have a set of UIButtons

I'm creating a tab-based app. I want one of the tabs to include the following:

-Have a set of UIButtons -When you click on one of the buttons it loads a view beneath the buttons -Each button has a different 开发者_高级运维view -No navigation controller just load the view on the same page without animation -Still can click on the other buttons

How do I go about doing this? Please help!


If the views are relatively lightweight, you can put them all into the .xib with hidden = YES, then put an IBOutlet to each. When you tap a button, hide the others and show the correct one.

If they're more complicated you might also want make some sort of ViewController-like object for each one of them to manage state.

You can also create and swap the subviews in code, again keeping around a pointer to each view or you can use tags to identify them.

0

精彩评论

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