我在尋找一些建議,可能會導致我的IOS應用程序中的CPU出現問題。CPU運行在100%以上
該應用程序運行良好,過了一段時間後,CPU將保持高速運行。我使用UICollectionView來顯示使用線程生成和編輯的水平縮略圖。當我使用UICollectionView並滾動圖像時,尖峯似乎發生。
我發佈了一個問題的屏幕截圖,下面的代碼是我用來編輯圖像的。
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImage *imageWithEffect = [self editImage:[[self.activeEffectsArray objectAtIndex:index] objectAtIndex:0] ImageToEdit:self.thumbnailImage];
dispatch_async(dispatch_get_main_queue(), ^{
[imageViewWithEffect setImage:imageWithEffect];
[activityIndicator removeFromSuperview];
[[self.activeEffectsArray objectAtIndex:index] insertObject:imageWithEffect atIndex:2];
});
});
- (UIImage *)editImage:(NSString *)effectName ImageToEdit:(UIImage *)tmpImage {
EffectBigApple *effectBigApple = [[EffectBigApple alloc] init];
if([effectName isEqualToString:@"BigApple 1"]){
return [effectBigApple processImage:tmpImage filterType:@"BigApple 1" sliderValue:1 type:nil];
}
if([effectName isEqualToString:@"BigApple 2"]){
return [effectBigApple processImage:tmpImage filterType:@"BigApple 2" sliderValue:1 type:nil];
}
if([effectName isEqualToString:@"BigApple 3"]){
return [effectBigApple processImage:tmpImage filterType:@"BigApple 3" sliderValue:1 type:nil];
}
if([effectName isEqualToString:@"BigApple 4"]){
return [effectBigApple processImage:tmpImage filterType:@"BigApple 4" sliderValue:1 type:nil];
}
return nil;
}
這可能是另一段代碼,是造成它,但我不知道?
我已在editImage中添加。謝謝 – ORStudios
請記住,我們正在尋找密集的部分,這不是它。深入一層,請顯示'processImage:' –