我具有由圖像的陣列,在其上我然後運行的動畫延遲上在IOS
[myUIImageView startAnimating]
我希望動畫一旦運行,則停止對3秒,然後重複。
我需要運行這個動畫在一個單獨的線程,這樣我在viewDidLoad中有
NSThread *animationThread = [[NSThread alloc] initWithTarget:self selector:@selector(startAnimTask) withObject:nil waitUntilDone:NO];
[animationThread start];
,然後
-(void) startAnimTask {
//create array of images here; animationDuration (3) and animationRepeatCount (1)
[self setUpAnimation];
while (true){
[myUIImageView startAnimating];
usleep(3);
[myUIImageView stopAnimating];
usleep(3);
}
}
使用這種方法,我收到一個內存警告。我也試過在MainThread上運行啓動和停止,但沒有運氣。
任何想法?
如果不是這種是performSelectorOnMainThread?它似乎不工作,只是執行選擇器 –
什麼//重複然後參考? –