0

私は本当にこれにこだわっています。リスト ビューが独自のものである 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] * 終了中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:]: インスタンス 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例外

4

3 に答える 3

1

ここでのクラッシュは非常に明確で、Nick と Sean によって適切に説明されています。

さらに重要な問題は、ダウンロード操作で MBProgressHUD に不適切な使用パターンを適用していることです。あなたがすべきことは、hud を作成し、ある種のダウンロード進行デリゲート コールバックで進行状況を更新することです。

見るべき例はhttps://github.com/jdg/MBProgressHUD/blob/master/Demo/Classes/HudDemoViewController.m#L156で、次のデリゲート コールバックと一緒ですhttps://github.com/jdg/ MBProgressHUD/blob/master/Demo/Classes/HudDemoViewController.m#L226 .

于 2012-03-14T11:11:50.157 に答える
1

更新の進行状況メソッドはパラメーター (float) を取るため、セレクターの末尾にコロンが必要です。

目標 C では、次のようになります。

@selector(refreshProgress:)

これと同じではありません:

@selector(refreshProgress)

これらは異なるメソッド名です。

于 2012-01-30T12:48:35.753 に答える
0

方法があれば

- (void)productsDownloadProgress:(float)progress count:(int)count

そのセレクターは

productsDownloadProgress:count:

いいえ

productsDownloadProgress:

したがって、セレクターに「productsDownloadProgress:count:」の代わりに「productsDownloadProgress:」を指定すると、存在しないメソッドにセレクターが指定されます。HUD がそのセレクターを呼び出そうとすると、Objective-C ランタイムは指定したターゲット (この場合は「self」) でそれを探しますが、見つからず、NSInvalidArgument 例外をスローします。

ただし、無効なセレクターの問題を修正したとしても、おそらくまだ問題が発生するでしょう。あなたの productsDownloadProgress:count: メソッドは 2 つの引数を取り、どちらも基本型ですが、 [HUD showWhileExecuting:onTarget:withObject:animated:] メソッドは 1 つの引数しかとらないセレクターを必要としているようで、その引数は Objective-C でなければなりません物体。

これが withObject: 部分の目的です。Objective-C オブジェクトを指定すると、最初の引数としてメソッドに渡されます。

もちろん、Urban Airship については何も知らないので、うまくいくかもしれません。

于 2012-02-09T21:01:28.183 に答える