I want one UIViewController in my storyboard instanced by several class. So i let the field "class" empty in my storyboard (so by default, its UIViewController
?). Then I fill storyboard ID with "MyGenericView
".
Here is some class:
@interface ClassA: UIViewController
@interface ClassB: UIViewController
MyGenericView
contains all prototype I need to build my view in ClassA and ClassB. Here is how I instancied my ClassA
:
ClassA *myClass = (ClassA*)[storyboard instantiateViewControllerWithIdentifier:@"MyGenericView"];
Finally, my view is showed in the app but code in my ClassA
is never called. Object returned by instantiateViewControllerWithIdentifier
is an UIViewController
, cast don't work.
I don't want to fill field "class" with ClassA because I want to reuse this view for ClassB
. However I don't want to duplicate this view in my storyboard.
Dunno if it seems clear for you, I apologize for my bad english :)
Thanks!