【发布时间】:2012-01-30 12:36:55
【问题描述】:
我真的被这个困住了。 我们有一个 IAP,其中列表视图是我们自己的,我们直接指向 UADetailView 进行购买。正因为如此,我们没有进度条来告诉用户下载进展如何,而且我们的下载量很大。 我以为我可以使用 MBProgressHud,但我遇到了问题。我似乎无法将 UA 的进度传递给 HUD。如果我使用一个简单的计数器来计时,HUD 一切正常。就像他们自己的样本一样。
这里是HUD调用;
- (void)showWithLabelDeterminate {
HUD = [[MBProgressHUD alloc] initWithView:self.view.window];
[self.view.window addSubview:HUD];
// Set determinate mode
HUD.mode = MBProgressHUDModeDeterminate;
HUD.delegate =self;
HUD.labelText = NSLocalizedString(@"DownLoading","");
// myProgressTask uses the HUD instance to update progress
[HUD showWhileExecuting:@selector(refreshProgress) onTarget:self withObject:nil animated:YES];
}
以及我尝试使用的刷新;
- (void)refreshProgress:(float)progress {
while (progress < 1.0f)
NSLog(@"++ progress for HUD: %f", progress);
HUD.progress = progress;
}
但是,当我运行它时,应用程序崩溃并显示此日志...
2012-01-30 12:23:18.838 isengua-en[12730:3827] -[UAProductDetailViewController refreshProgress]:无法识别的选择器发送到实例 0x3e2c10 2012-01-30 12:23:18.840 isengua-en[12730:3827] * 由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因:'-[UAProductDetailViewController refreshProgress]:无法识别的选择器发送到实例 0x3e2c10' * 第一次抛出调用栈:(0x30caa8bf 0x37e4f1e5 0x30cadacb 0x30cac945 0x30c07680 0x30c0922b 0xf4e59 0x37cbca91 0x37d505a1 0x36447c1d 0x36447ad8) 终止调用抛出异常[
有人遇到过同样的问题并解决了吗?
更新更新...
- (void)showWithLabelDeterminate {
HUD = [[MBProgressHUD alloc] initWithView:self.view.window];
[self.view.window addSubview:HUD];
// Set determinate mode
HUD.mode = MBProgressHUDModeDeterminate;
HUD.delegate =self;
HUD.labelText = NSLocalizedString(@"DownLoading","");
// myProgressTask uses the HUD instance to update progress
[HUD showWhileExecuting:@selector(productsDownloadProgress:) onTarget:self withObject:nil animated:YES];
}
- (void)productsDownloadProgress:(float)progress count:(int)count {
HUD.progress = progress;
UALOG(@"[StoreFrontDelegate] productsDownloadProgress: %f count: %d", progress, count);
if (count == 0) {
NSLog(@"Downloads complete !");
}
}
这个在购买按钮上
- (void)purchase:(id)sender {
self.navigationItem.rightBarButtonItem.enabled = NO;
[UAStoreFront purchase:product.productIdentifier];
[self.navigationController popViewControllerAnimated:NO];
[[UAStoreFront shared] setDelegate:self];
[self showWithLabelDeterminate];
}
崩溃日志:
2012-01-30 13:12:45.555 isengua-en[12886:6e27] -[UAProductDetailViewController productsDownloadProgress:]:无法识别的选择器发送到实例 0x3f7f70 2012-01-30 13:12:45.557 isengua-en[12886:6e27] * 由于以下原因而终止应用程序 未捕获的异常“NSInvalidArgumentException”,原因: '-[UAProductDetailViewController productsDownloadProgress:]: 无法识别的选择器发送到实例 0x3f7f70' * 第一次抛出调用栈:(0x30caa8bf 0x37e4f1e5 0x30cadacb 0x30cac945 0x30c07680 0x30c0922b 0xf5e21 0x37cbca91 0x37d505a1 0x36447c1d 0x36447ad8) 终止调用抛出异常
【问题讨论】:
-
您能否给我们一些详细信息,您的 showWithLabelDeterminate 在哪里以及您的 refreshProgress 在哪里。谢谢
-
@MartinMoizard 我在 UAProductDetailViewController.m 中有这个 -(void)purchase 激活它
标签: ios urbanairship.com hud