我正在使用NSTimer呼叫设备每24.5秒拍摄一次照片。
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async( dispatch_get_main_queue(), ^{
_photoTimer = [NSTimer scheduledTimerWithTimeInterval:24.5 target:self selector:@selector(takePhotos) userInfo:nil repeats:YES];
});});
在第11次,我切换到主队列并调用NSTimer停止,但它不会推送到下一页。
-(void)takePhotos{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//taking photos....
currenPageNumber +=1;
dispatch_async( dispatch_get_main_queue(), ^{
//showing photos
});
dispatch_async( dispatch_get_main_queue(), ^{
if (currentCount == 11){
[_photoTimer invalidate];
_photoTimer = nil;
UploadVC * uploadVC = [self.storyboard instantiateViewControllerWithIdentifier:@"UploadVC"];
[self.navigationController presentViewController:uploadVC animated:YES completion:nil];
}
});
});
}