Monday, August 5, 2013

データを読み込むときのロード画面を作る

前回の更新から長らく時間が空いてしまいましたが、最近は開発を再会しております。

今回はデータを読み込むときの待機画面を作ってみましょう
これです


こんな感じに書けばOKです。
下のviewへのタッチイベントも吸収してくれます

    UIView *loading_view = [[UIView alloc]initWithFrame:self.view.bounds];
    loading_view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    indicator.center = CGPointMake(loading_view.bounds.size.width / 2, loading_view.bounds.size.height / 2);
    
    [indicator startAnimating];
    [loading_view addSubview:indicator];
    
    [self.view addSubview:loading_view];


あとちゃんと読み込んでるよーとユーザーに伝えるために、上のちっちゃいくるくるも動かすと良いですね。これです。

    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

No comments:

Post a Comment