Inheritance UIViewController in ios

| | August 5, 2015

I have FirstViewController(parent) an I have created it in storyboard, it integrating camera(AVCaptureSession) and containing (UILabel, UIButtons, UIView, UIImage), I have created SecondViewController which inherits FirstViewController to avoid duplicate the FirstViewController and I am changing label in the SecondViewController.

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"### viewDidLoad ###");
    text = @"Je me prends en photo";
    [self setTextField:text];
    [CaptureSession initializeCamera];
}

to modify label

-(void) setTextField : (NSString*) text{
self.textFieldDisplay.text = text;
}

SecondViewController.m

- (void)viewDidLoad {
   [super viewDidLoad];
   [CaptureSession initializeCamera];
   textDisplay = @"Prends un selfie et défie tes amis !";
   [super setTextField:textDisplay];   
}

My problème is I can’t display label in the SecondViewController !
if you have document concerning inheritance UIViewController I’ll take it.

2 Responses to “Inheritance UIViewController in ios”

  1. Finally I don’t use inheritance just I created static string in SecondViewController

    eg: static nsstring *test = @"test", and save it in delegate when I’m going in FirstViewController I test it in method and I change label in FirstViewController like I do.

  2. You can create a UIViewControllerGeneric with all the common properties, and then inherit both viewcontrollers from it, I think it’s the correct way

Leave a Reply