aboutsummaryrefslogtreecommitdiffstats
path: root/platform/ios/demo/Examples/ExamplesContainerViewController.m
blob: 3f1361b3168b5a07ebe36699ed69309d473ddd22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
//  ExamplesContainerViewController.m
//  Examples
//
//  Created by Jason Wray on 1/26/16.
//  Copyright © 2016 Mapbox. All rights reserved.
//

#import "ExamplesContainerViewController.h"

@interface ExamplesContainerViewController ()

@end
@implementation ExamplesContainerViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = self.exampleToLoad ?: @"Example Not Specified";

    if (NSClassFromString(self.exampleToLoad)) {
        UIViewController *childViewController = [[NSClassFromString(self.exampleToLoad) alloc] init];
        [self addChildViewController:childViewController];
        [self.view addSubview:childViewController.view];
        [childViewController didMoveToParentViewController:self];
    } else {
        UILabel *exampleNotFoundLabel = [[UILabel alloc] initWithFrame:self.view.frame];
        exampleNotFoundLabel.text = @"Example not found";
        exampleNotFoundLabel.font = [UIFont systemFontOfSize:72.f];
        exampleNotFoundLabel.adjustsFontSizeToFitWidth = YES;
        exampleNotFoundLabel.textAlignment = NSTextAlignmentCenter;
        exampleNotFoundLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        exampleNotFoundLabel.backgroundColor = [UIColor redColor];
        [self.view addSubview:exampleNotFoundLabel];
    }

    self.navigationController.hidesBarsOnSwipe = YES;
    self.navigationController.hidesBarsWhenVerticallyCompact = YES;
}

@end