iOS Urban Airship 进度和 HUD

标签 ios urbanairship.com hud

我真的被困在这个问题上了。 我们有一个 IAP,其中 ListView 是我们自己的,我们直接指向 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]: unrecognized selector sent to instance 0x3e2c10 2012-01-30 12:23:18.840 isengua-en[12730:3827] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UAProductDetailViewController refreshProgress]: unrecognized selector sent to instance 0x3e2c10' * First throw call stack: (0x30caa8bf 0x37e4f1e5 0x30cadacb 0x30cac945 0x30c07680 0x30c0922b 0xf4e59 0x37cbca91 0x37d505a1 0x36447c1d 0x36447ad8) terminate called throwing an exception[

有遇到同样问题并解决的吗?

更新变化...

- (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:]: unrecognized selector sent to instance 0x3f7f70 2012-01-30 13:12:45.557 isengua-en[12886:6e27] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UAProductDetailViewController productsDownloadProgress:]: unrecognized selector sent to instance 0x3f7f70' * First throw call stack: (0x30caa8bf 0x37e4f1e5 0x30cadacb 0x30cac945 0x30c07680 0x30c0922b 0xf5e21 0x37cbca91 0x37d505a1 0x36447c1d 0x36447ad8) terminate called throwing an exception

最佳答案

您的刷新进度方法采用一个参数( float ),因此您的选择器末尾应该有一个冒号:

在 objective-c 中,这:

@selector(refreshProgress:)

与此不同:

@selector(refreshProgress)

它们是不同的方法名。

关于iOS Urban Airship 进度和 HUD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9063956/

相关文章:

ios - 我如何响应点击 UNUserNotification?

ios - React-Native:如何为动态链接的一个构建添加多个 google-service-info plist 文件?

ios - 如何在文件管理器中快速读取json文件?

android - 将 urbanairship 添加到 config.xml 后,PhoneGap Android 应用程序崩溃

objective-c - 可调整大小的自定义 NSPanel

ios - 如何返回当前目录 (“.” )、父目录 (“..” 的 URLs

ios - 以下 iPhone 应用程序崩溃的原因可能是什么

iphone - APNS 提供列表 - 哪些公司是推送通知服务器提供商

godot - Godot 中的 HUD 后处理

iphone - 使用 UITabBarController 时在整个屏幕上覆盖一个 View ?