2015-02-10 50 views

回答

0

嘗試加入上海華:

[MBProgressHUD showHUDAddedTo:self.collectionView.superview animated:YES]; 

UPDATE

好吧,我檢查你的代碼,這有點搞砸了。所以

- (void)viewDidDisappear:(BOOL)animated { 
    NSLog(@"viewDidDisappear in Main Page"); 
    // Looks like you want to hide your HUD here. 
    // This code will be called right after [self.tabBarController setSelectedIndex:1], 
    // cause current with gonna disappear. 
    [MBProgressHUD hideHUDForView:self.view animated:YES]; 
} 

,如果你真的希望看到HUD(目前還不清楚它應該是多久可見): 這裏發生:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.row == 0) { 

     // You about to show HUD in your current VC views hierarchy 
     MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.collectionView.superview animated:YES]; 
     hud.labelText = @"Loading..."; 
     // But immediately switching to another. Current VC will be off screen. 
     // You will not see your HUD 
     [self.tabBarController setSelectedIndex:1]; 
    } 
... 

然後

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.row == 0) { 
     MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.tabBarController.view]; 
    // hide after 4 seconds 
    [hud hide:YES afterDelay:4]; 

... 
+0

嗨Orkenstein,我已經在uicollection視圖「didSelectItemAtIndexPath」方法添加同樣的事情,但它仍然沒有出現在查看@orkenstein – Koteswar 2015-02-12 05:22:45

+0

@Koteswa請分享你的代碼。 – orkenstein 2015-02-12 06:52:40

+0

請檢查此鏈接http://paste.ofcode.org/L7KGtcSJUqUEH7AKTrRiKY – Koteswar 2015-02-12 10:01:31