DKM
DKM

Reputation: 270

Main.storyboard does not load

I'm new to iOS and I'm making some exercises I'm stuck at the begining. I'd like to use standard Main.storyBoard which looks like this: enter image description here

And the AppDelegate.m file looks like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
//    CGRect bounds = [[UIScreen mainScreen] bounds];
//    self.window = [[UIWindow alloc] initWithFrame:bounds];
//    
//    self.controler = [[ViewController alloc] init];
//    
//    self.window.rootViewController = self.controler;
//    
//    [self.window makeKeyAndVisible];

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
    UIViewController *vc = [storyboard instantiateInitialViewController];

    // Set root view controller and make windows visible
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];



    return YES;
}

And ViewControler if it will be usefull:

@interface ViewController ()

@property UIView *viewM;

@end

@implementation ViewController

-(void) loadView
{
    CGRect bounds = [[UIScreen mainScreen] bounds];

    self.viewM = [[UIView alloc] initWithFrame: bounds];
    self.view = self.viewM;

}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"AHAHH DOTKNIETO EKRANU");
}

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    self.view.backgroundColor = [UIColor blueColor];
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];


    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 200, 200, 50)];

    //SET TEXT FOR THIS LABEL

    label.text = @"TEXTTTTTT";
    [self.view addSubview:label];

    // Do any additional setup after loading the view, typically from a nib.
}

Everytime I run this sample it loads me View which is white instead of the image above. What's not right with it? I'm using Xcode 5.1.1 version.

Upvotes: 1

Views: 6403

Answers (1)

Fogmeister
Fogmeister

Reputation: 77661

In the project - General page you should see a setting for "Main Interface".

Remove all the code in the applicationDidFinishLaunching except return YES; and make sure this is set to Main.

enter image description here

Upvotes: 5

Related Questions