2011-07-18 44 views
0

因爲我是iPhone新手我有一個litle問題。我想在我的應用程序中使用UIActivityIndi​​catorView。由於我使用indicatorView的蜜蜂成功,但我想用模糊背景顯示IndicatorView,所以我不能點擊我當前活動上的按鈕。在UIActivityIndi​​catorView需要幫助 - iPhone

請朋友

指導我一些教程或一些代碼。

感謝一堆事先

回答

4

在這裏你走這是我的實施,但你可以修改。將代碼發佈到應用程序委託中並在您的應用程序中的任

#pragma mark - 
#pragma mark Waiting View 
- (void)showWaitingView { 

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 

    CGRect frame = CGRectMake(90, 190, 32, 32); 
    UIActivityIndicatorView* progressInd = [[UIActivityIndicatorView alloc] initWithFrame:frame]; 
    [progressInd startAnimating]; 
    progressInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; 

    frame = CGRectMake(130, 193, 140, 30); 
    UILabel *waitingLable = [[UILabel alloc] initWithFrame:frame]; 
    waitingLable.text = @"Processing..."; 
    waitingLable.textColor = [UIColor whiteColor]; 
    waitingLable.font = [UIFont systemFontOfSize:20];; 
    waitingLable.backgroundColor = [UIColor clearColor]; 
    frame = [[UIScreen mainScreen] applicationFrame]; 
    UIView *theView = [[UIView alloc] initWithFrame:frame]; 
    theView.backgroundColor = [UIColor blackColor]; 
    theView.alpha = 0.7; 
    theView.tag = 999; 
    [theView addSubview:progressInd]; 
    [theView addSubview:waitingLable]; 

    [progressInd release]; 
    [waitingLable release]; 

    [window addSubview:[theView autorelease]]; 
    [window bringSubviewToFront:theView]; 
    [pool drain]; 
} 

- (void)removeWaitingView { 
    UIView *v = [window viewWithTag:999]; 
    if(v) [v removeFromSuperview]; 

} 
+0

,所以我應該怎麼稱呼它從我的Viewcontroller.m文件? – Shah

+0

,這是否繼續在我的過程中工作?同時讓我看看等待的圖標? – Shah

+1

是的。你可以像這樣使用它[appDelegate showWaitingView];和[appDelegate removeWaitingView];我假設你知道如何在其他類中獲得appDelegate。 –

0

首先,你必須添加一個視圖中,帶有黑色背景阿爾法0.3什麼。然後在視圖上方添加活動指示器。

// an example 
[self.view addSubview:aSemiTransparentBlackView]; 
[self.view addSubview:activityIndicator]; 
0

也可以試試這個:

-(UIAlertView *)showActivityIndicator :(NSString *)message 
{ 

alertViewProgress = [[UIAlertView alloc] initWithTitle:message message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];  
UIActivityIndicatorView *activity =[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(120,50,37,37)]; 
    activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; 
    [activity startAnimating]; 
    [alertViewProgress addSubview:activity]; 
    [activity release]; 
    [alertViewProgress show]; 
    return alertViewProgress; 
} 
相關問題