0

私はMBProgressHUD自分のプロジェクトで利用しています。を利用するメソッドshowWhilePerformingSelector:を呼び出しているメソッドを使用していますNSURLConnectionNSURLConnectionデリゲートメソッドが起動される前にスレッドが強制終了されるため、セカンダリスレッドでの使用に問題があるという別のStackOverflowの質問を読みました。

本質的に、問題は、MBProgressHUDshowWhilePerformingSelector:メソッドが選択したメソッドを別のスレッドで実行するかどうかです。もしそうなら、どのように私は私のメインスレッドを利用して私の実行に取り掛かるNSURLConnectionでしょうか?

4

1 に答える 1

1

どのバージョンMBProgressHUDを使用していますか?v0.4(最後)では、そのような方法はありません。代わりにshowWhileExecuting、次のようになります。

    /**
 * Shows the HUD while a background task is executing in a new thread, then hides the HUD.
 *
 * This method also takes care of NSAutoreleasePools so your method does not have to be concerned with setting up a
 * pool.
 *
 * @param method The method to be executed while the HUD is shown. This method will be executed in a new thread.
 * @param target The object that the target method belongs to.
 * @param object An optional object to be passed to the method.
 * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use
 * animations while disappearing.
 */
- (void)showWhileExecuting:(SEL)method 
                  onTarget:(id)target 
                withObject:(id)object 
                  animated:(BOOL)animated;

あなたがすべきことは、HUDだけを表示し、代理人が解雇されたときにそれを削除することです。フォーマットを改善するのではなく、接続を実行する必要があります。非同期接続を使用している限り、すべて問題ありません。

このようなもの。

于 2011-06-17T06:31:25.567 に答える