I am trying set custom class name to storyboard programmatically in iOS.
I have storyboard with viewcontroller MyFirstViewController and set class name as MyFirstViewController
Now I create another viewcontroller SecondViewController which extends MyFirstViewController
SecondViewController *vcsecond = (SecondViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"MyFirstViewController"];
[self.navigationController pushViewController:vcsecond animated:YES];
When I run this app my SecondViewController viewDidLoad method not call, it calls MyFirstViewController viewDidLoad method.
I get vcsecond as object of MyFirstViewController.
Please help me how to open SecondViewController using MyFirstViewController XIB.
I only want to inherit all the functionality of MyFirstViewController to SecondViewController and also override some method's here and execute some new code in overrided method with additional functionality.
Design of the both viewcontroller is same only add some new functionality using overriding method's.

In above screen TabSearchForDocViewController is my MyFirstViewController controller.
So my actual question is----------
I have comman storyboard page for two view controller. My SecondViewController is extends MyFirstViewController. Now I want to open my SecondViewController using comman storyboard page. Is it possible to set class name programmatically?
instantiateViewControllerWithIdentifier will always return an instance of the class specified in the corresponding scene in the storyboard - you cannot override this at run time.
I would suggest that you create a 'thin' object which is the class that you specify in the storyboard scene. You can then create other object classes (using inheritance) that implement the view controller functionality using a delegation pattern. You can then instantiate the appropriate delegate instance at run time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With