NSProgressIndicator をシート上で動かそうとしたときに動きませんでした。
このメソッドは指定されたシートのためのモーダル・イベント・ループを同期的に実行します。表示するシートをキーウィンドウにして、実行ループを開始します。そして、そのためのイベントを処理します。アプリケーションが実行ループ中のあいだ、シートに関連付けされてない限り、他のどんなイベント(マウス、キーボード、またはウィンドウ-クローズ・イベントを含む)にも応答しません。また、モーダル実行ループに関連付けられていないどんな(タイマー発動のような)タスクも実行しません。つまり、このメソッドはイベントを処理するために必要なCPU時間を費し、それらをモーダル・ウィンドウに関連付けられたアクション・メソッドへ送ります。
ということで、シート上のインジケータの更新を反映させるには、
for (NSInteger index = 0; index < 1000; index++) {
[indicator incrementBy:1.0];
[indicator displayIfNeeded];
}
ウィンドウとかビューとかに直接 display* を送信してやります。
0 件のコメント:
コメントを投稿