我在按钮操作中调用了两种方法,
- (IBAction)capture:(id)sender
{
/*1*/ [self.capturingWindow capturePhoto]; //capture pictures and pass the paths to imagePathsArray
NSLog(@"imagePathsArray.count---%d",imagePathsArray.count) ;
/*2*/ [self displayImagesOnScrollView:imagePathsArray];
}
我在图像捕获按钮中有这两种方法。
1. [self.capturingWindow capturePhoto]; //capture pictures and pass the paths to imagePathsArray
此方法捕获图像并将捕获图像的路径填充到 imagePathsArray
2. [self displayImagesOnScrollView:imagePathsArray];
此方法使用这些填充的 imagePathsArray,
在各自的图像视图中显示图像..
问题是方法:1。[self.capturingWindow capturePhoto];
需要一些时间来捕获和加载到 imagesPathsArray 的路径。
同时,方法:2。[self displayImagesOnScrollView:imagePathsArray];
触发,因此由于数组超出范围而发生崩溃。
我试过了
[ self performSelector:@selector(displayImages) withObject:nil afterDelay:1]
而不是直接使用该方法..
仍然没有用 // 它将问题减少了 40%,但它仍然可以重现
我希望第二种方法只需要在第一种方法之后调用。
但最好保持较少的延迟(低优先级)