Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicating views

I want to create a view with some controls inside, a text field and some buttons, and I want to duplicate this to show them as content of a tab in a tabview. Each tab must has an instance of this view. Directions?

like image 622
gcstr Avatar asked Jul 31 '26 20:07

gcstr


2 Answers

Dave DeLong is close and somewhat your question contains the answer ("each tab must has an instance of the view"). Create a UIViewController subclass to programatically create the view, or to load a NIB. Then instantiate several instances of your UIViewController subclass and add them all to the UITabViewController's viewControllers property.

You'll want to spend some time with the View Controller Programming Guide. The fact that you are making multiple instances of the same UIViewController subclass really has little impact on the solution.

like image 157
Rob Napier Avatar answered Aug 03 '26 20:08

Rob Napier


Ehm...I'm not really sure whether I correctly understood what you'd like to do. The word "duplicate" doesn't sound very good since most often in programming it indicates a "smell".

I'm not a specialist of cocoa, neither of objective-c, but I guess you could somehow put your controls inside some kind of container control and instantiate (reuse rather than duplicate) this container control on your tab view or wherever you'd like.

like image 29
Juri Avatar answered Aug 03 '26 18:08

Juri



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!