Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common View used by Multiple View Controllers in Storyboard

I've read through both the iOS View Controller Programming Guide and iOS View Programming Guide and can't work out the best way to do the following without a lot of replication in my code or storyboard.

I'm working on a simple maths tutorial program for my children which has a View with a "NumberPad", digits 0-9, in it along with an SKScene for some animation.

So far I have one viewcontroller that handles the presentation of simple add, subtract, mulitply and divide problems which is working well.

I'd like to use the same number pad for a viewcontroller that will handle long divison and multi-digit multiplication and that's where I run into trouble trying work out how to reuse the NumberPad/SKScene view.

I'm pretty sure I can work out how to create this programatically from any number of examples on how to programatically switch from one View Controller to another. But I'd much rather use interface builder to achieve this given the ease with which I can layout the controls.

like image 214
TJA Avatar asked May 20 '14 02:05

TJA


1 Answers

Have you ever considered ContainerView? ContainerView is suitable to create common view for different viewcontrollers in your project. ContainerView is very powerful if you know how to use it. I have been using quite a lot in my project once I know how to use it.

Yesterday, there was an almost similar question about "common UITableView for all view controllers?", you may see my answer there:-

How to create common UITableView for all view controllers?

This link might help too: How to use a 'Container View' in iOS?

like image 115
Ricky Avatar answered Oct 01 '22 21:10

Ricky