-1

UIActivityIndicatorViewビューロードの前に を追加する方法。Web サーバーからデータを取得しています。

これが私のコードです

spinner=[[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(225, 115, 30, 30)];
[spinner setBackgroundColor:[UIColor clearColor]];
[spinner setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[self.view addSubview:spinner];
[spinner startAnimating];


objCountryPreferences=[[CountryPreferences alloc]init];
objLanguagePreference=[[LanguagePreference alloc]init];
objMobilePrefixParser=[[MobilePrefixParser alloc]init];

//これは異なる Web サービスを呼び出しています

[objMobilePrefixParser getMobilePrefix];
[objLanguagePreference  languagePreference];
[objCountryPreferences getCountryIdArr];
4

3 に答える 3

1

ActivityIndi​​cator を別のメソッドに追加し、それを使用して呼び出します

[self performSelector:@selector(addActivityIndicator) withObject:nil afterDelay:0.1];
于 2013-01-31T07:16:54.357 に答える
0

進行状況インジケーターがアニメーション化されていないということですか。はいの場合、別のスレッドでstartAnimatingを実行する必要があります。[スピナーperformSelector:@selector(startAnimating)]

于 2013-01-31T07:18:00.340 に答える
0

スピナーを作成します:

  self.spinner=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    self.spinner.frame=CGRectMake(152,183,60,60);
    // display spinner in StatusBar it Optional for you
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    [self.spinner sizeToFit ];    
      /*-----------Change Size of UIActivityIndicatorView-------------*/
        self.spinner.transform = CGAffineTransformMakeScale(2, 2);
    [self.webView addSubview:self.spinner];
   

UIWebView の Delegate メソッドを使用します。

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [self.spinner startAnimating];
     // display  spinner in StatusBar it Optional for you
     [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [self.spinner stopAnimating];
    // Remove  spinner in StatusBar it Optional for you
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

}
于 2013-01-31T07:39:14.100 に答える