Search code examples
objective-cios5uiviewcontrollerstoryboard

Subclass of UIViewController shows black screen


I created a Subclass of UIViewController in my Project and linked it to a View which is modal-pushed by the "RootViewController". I made absolutely no changes to the derived class, but when the "SecondView" is pushed it turns black every time. If i link that view to the standard UIViewController class everything works fine?

Since the "SecondViewController" is derived from UIViewController I can only guess that the Problem has to do with the alloc/init function but I have no idea where to start.

I can provide the sample code I have in front of me now if necessary.

This is the derived subclass:

#import "SecondViewController.h"

@interface SecondViewController ()

@end

@implementation SecondViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self; }

- (void)loadView {}

- (void)viewDidLoad {
    [super viewDidLoad]; }

- (void)viewDidUnload {
    [super viewDidUnload];}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait); }

@end

Header:

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController

@end

Solution

  • - (void)loadView
    {
        // If you create your views manually, you MUST override this method and use it to create your views.
        // If you use Interface Builder to create your views, then you must NOT override this method.
    }
    

    FYI, the comment is automatically generated too.