我在 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/