Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch single view based application view on iPhone

I have a simple view based application. I want to switch this original view for another view when I push a button on the original view. I do not want to use a navigationviewcontroller, or switchviewcontroller, I simply want to swap the root view for another.

Thanks, Joe

like image 344
Atma Avatar asked Jun 19 '26 11:06

Atma


1 Answers

This isn't recommended by apple. If you have multiple views, you should be using a TabBar controller or a Navigation Controller. One reason is that messages like viewDid/WillAppear don't get sent when you improperly add views.

If you don't want to display a navigation bar, then you you can set it to hidden and no one will ever know the are in a Navigation based app. You can also prevent views from animating in from the side when pushing a view controller.

The other accepted option is loading a "backing" view and never changing it. You can switch out any subviews on this backing view. You might never see the backing view in the app, but it is there just for you to remove and add views.

like image 64
Corey Floyd Avatar answered Jun 22 '26 00:06

Corey Floyd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!