2012-01-10 11 views
1

のために実行していない私はMBProgressHUDため、以下の方法があります。performSelector:withObject:afterDelayはMBProgressHUD

[progressHUD performSelector:@selector(hide:) 
        withObject:[NSNumber numberWithBool:YES] 
        afterDelay:kMessageHidingDelay]; 

は、遅延は、しかし、それは2.0秒後に非表示を呼び出していない、ここでは2.0です。私はhide関数にブレークポイントを入れようとしましたが、そこには到達しません。何か案が?

progressHUD = [[MBProgressHUD alloc] initWithView:viewToAttach]; 

      // Add HUD to screen 
      [viewToAttach addSubview:progressHUD]; 
      progressHUD.labelText = @"Logging In"; 
      progressHUD.removeFromSuperViewOnHide = YES; 
      // Show the HUD while the provided method executes in a new thread 

      [progressHUD show:YES]; 
+0

非表示にすることがあります: - (無効)非表示:(BOOL)アニメーションafterDelay:(NSTimeInterval)遅延を、 ? – Alin

+0

私はMBProgressHUDでその機能を持っていません...私はこれが私のコードの問題だと思うし、HUDが回転しているときに何かをしているときに何かが単純化されているときにスレッド化しています仕事は完璧。どんな考え? – adit

+0

あなたのMBProgressHUDバージョンのバグかもしれません。 https://github.com/jdg/MBProgressHUDから最新のソースを入手して試してみてください。また、UI以外のスレッドからUIメソッドを呼び出さないようにしてください。遅延されたメソッドを別のスレッドから呼び出すと、それはあなたの問題です。 – Alin

答えて

0

メインスレッドでセレクタを実行しようとしている可能性があります(すべてのUI変更はメインスレッドで行う必要があります)? performSelectorOnMainThread:

0

はMBProgressHUD使用して、このコードを表示するには: -

HUD = [[MBProgressHUD alloc] init]; 

    [self.view addSubview:HUD]; 

    HUD.delegate = self; 

    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; 

    where myTask is 

    - (void)myTask 
    { 
    "Your Code" 
    } 

を、あまりにもMBProgressHud

- (void)hudWasHidden:(MBProgressHUD *)hud 
    { 
     // Remove HUD from screen when the HUD was hidded 
     [HUD removeFromSuperview]; 
     [HUD release]; 
    HUD = nil; 
    } 

を非表示にし、あなたのCostomViewでハッドを表示したい場合は、このコードを使用

HUD = [[MBProgressHUD alloc] init]; 

[self.view addSubview:HUD]; 

// Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators) 
HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Your Image Name.png"]] autorelease]; 

// Set custom view mode 
HUD.mode = MBProgressHUDModeCustomView; 

HUD.delegate = self; 

HUD.labelText = @"Completed"; 

[HUD show:YES]; 

[HUD hide:YES afterDelay:3]; 

}

0

あなたが使用していない理由をMBProgressHud

[progressHUD hide:YES]; 
関連する問題