Last active
December 17, 2015 20:59
-
-
Save CH3COOH/5671275 to your computer and use it in GitHub Desktop.
iOSで遅延起動させてみた その2 ローディング画面->起動画面への遷移
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
| { | |
| self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; | |
| // ローディング画面 | |
| self.viewControllerA = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease]; | |
| // 起動画面とする | |
| self.viewControllerB = [[[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil] autorelease]; | |
| // まずはローディング画面を表示するでござる | |
| self.window.rootViewController = self.viewControllerA; | |
| [self.window makeKeyAndVisible]; | |
| return YES; | |
| } | |
| - (void) startApplication { | |
| // ホーム画面に切り替えるでござる | |
| self.window.rootViewController = self.viewControllerB; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ローディング画面のロード | |
| - (void)viewDidLoad | |
| { | |
| [super viewDidLoad]; | |
| // Do any additional setup after loading the view, typically from a nib. | |
| NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://ch3cooh.jp/"]]; | |
| [NSURLConnection sendAsynchronousRequest:req | |
| queue:[NSOperationQueue mainQueue] | |
| completionHandler:^(NSURLResponse *res, NSData *data, NSError *error) { | |
| // なんか重たい処理とかやってる | |
| [NSThread sleepForTimeInterval:5]; | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| id appDelegate = [[UIApplication sharedApplication] delegate]; | |
| [appDelegate performSelector:@selector(startApplication)]; | |
| }); | |
| }]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment