iphone - 有时 MBProgressHUD 不显示

标签 iphone ios ios4 mbprogresshud

我在 uitableview 中显示了歌曲标题列表以及“购买”按钮。点击该按钮时我正在显示 MBProgressHUD。但有时它不会显示。它还会禁用用户交互,如下所示代码。

但为什么有时不显示 MBProgressHUD?

请告诉我,非常感谢。

Below is the code

-(void) buySong:(UIButton *)button
    {
      self.view.userInteractionEnabled = NO;

      self.navigationController.navigationBar.userInteractionEnabled = NO;

      MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
      hud.labelText = @"Proessing...";
      hud.yOffset = -80;

      UITableViewCell *cell = (UITableViewCell *)[[button superview] superview];
      NSIndexPath *indexPath = [[self tblViewChildrenPoems] indexPathForCell:cell];

      PSSongTags *songTags = [self.songsArray objectAtIndex:indexPath.row];
      [ [PurchaseViewController sharedPurchaseManager] startPurchase:songTags];

    }

最佳答案

试试这个代码可能对你有帮助...

在您的 .h 文件中导入 .

 #import "MBProgressHUD.h"

设置委托(delegate)。

MBProgressHUDDelegate

之后

MBProgressHUD *HUD;

在您的 .m 文件中//在您想要显示的位置添加此代码 ...

HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
    [self.navigationController.view addSubview:HUD];
    HUD.delegate = self;
    HUD.labelText = @"Authorizing...";
    [HUD show:YES];

以及当您的流程结束使用 hide ..

[HUD Hide:YES];

并在您的 m 文件中设置隐藏委托(delegate)......

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

快乐编码...

关于iphone - 有时 MBProgressHUD 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12241914/

相关文章:

iOS 应用程序切片或细化不起作用

ios - 无法从另一个 View Controller 获取 TableView 数据

ios - Swift 核心数据问题 (Xcode 6)

android - 是否可以在 iOS 或 Android 上的另一个应用程序中嵌入下载按钮 - 而无需离开原始应用程序?

iphone - UISearchDisplayController "No Results"文本

iphone - 如何知道哪个 xib 文件使用了图像?

android - 将测试数据导入应用程序的简单方法

ios - 启用 Bitcode 的 Apple APP Store 上的移动应用程序大小

css - iOS 4.3 在 PhoneGap 应用程序中使用了错误的字体

iphone - iOS 版本之间的 UIKeyboardWillShowNotification、UIKeyboardWillHideNotification 和 NSNotificationCenter 问题