1
我有這樣的代碼:IOS:在其執行停止的方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = NO;
UITouch *touch = [touches anyObject];
point =[touch locationInView:imageView];
[self openImages];
}
evrytime我觸摸屏它稱之爲「openImages」的方法;
- (void) openImages{
// some code....
for(int i = 0; i < 200; i++){
for(int j = 0; j < 200; j++){
//some code...
}
}
}
,那麼你可以看到,「openImage」是一個沉重的方法,因爲有一個雙迴路我在哪裏開一些的UIImage(但它不是問題)。 我的問題是:我可以做什麼來阻止每次我觸摸屏幕openImages,並多稱一次(因爲如果我經常觸摸屏幕應用程序崩潰)。 你能幫我嗎?
Oooohoha,不錯!你會使用outer for循環來檢查isCancelled嗎? – 2012-02-08 11:43:57
你能給我一個例子的鏈接?或者你可以發佈一個例子嗎? – CrazyDev 2012-02-08 11:50:59
@JonasByström,這取決於循環內發生的情況。沒有這些知識,我會在兩個循環中檢查isCancelled。 – hoha 2012-02-08 11:53:29