2011-08-23 98 views
0

我有一些代碼來處理一個大尺寸的文件,這將需要很長時間。 我希望進步啓動時顯示與UIActivityIndi​​catorView景色和隱藏的觀點,當它完成用UIActivityIndi​​catorView顯示UIView需要很長時間才能做點什麼

的代碼如下

[[NSNotificationCenter defaultCenter] postNotificationName:@"DisplayProcessing" object:nil]; 

[self dosomething];//take a long time     

[[NSNotificationCenter defaultCenter] postNotificationName:@"HideProcessing" object:nil]; 

但其excution順序是:

[[NSNotificationCenter defaultCenter] postNotificationName:@"DisplayProcessing" object:nil]; 

[[NSNotificationCenter defaultCenter] postNotificationName:@"HideProcessing" object:nil]; 

[self dosomething];//take a long time  

所以有沒什麼顯示

歡迎任何評論

回答

0

爲什麼不使用線程?開始你的指標在方法DoSomething的,然後停止該指標

開始指示器主要方法和替換

[self dosomething];

[self performSelectorOnMainThread:@selector(dosomething:) withObject:nil waitUntilDone:NO]; 

,並停在這裏的活動

相關問題