IOS5.1 앱에서 CorePlot-Cocoa Touch를 활용합니다. scatterplots, dataForPlots, legend 등의 설정에는 시간이 걸리기 때문에 UIActivityIndicatorView를 포함하여 사용자에게 무슨 일이 일어나고 있음을 나타 내기로 결정했습니다. (CPTPlot *) 플롯UIActivityIndicatorView와 CorePlot-CocoaTouch를 사용하면 메모리 오류가 발생합니다.
: - (NSUInteger) numberOfRecordsForPlot
:
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; progressInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; progressInd.center = self.view.center; [progressInd sizeToFit]; progressInd.hidden = NO; progressInd.alpha = 1.0; [self.view addSubview:progressInd]; [progressInd startAnimating]; [self.view bringSubviewToFront:progressInd]; [self performSelectorInBackground:@selector(DoMakeupPlot) withObject:nil]; } - (void)DoMakeupPlot { … set up plot … including datasource and delegate [progressInd stopAnimating]; [progressInd removeFromSuperview]; progressInd = nil; }
지금이 그러나 그것은 플롯 데이터 소스 루틴을 호출이 개 스레드가 될 것이 분명입니다, 경우에 작동하는 것 같다 - (의 NSNumber *) numberForPlot : (CPTPlot *) 플롯 필드 : (NSUInteger) fieldEnum recordIndex : 경우에 수행 (NSUInteger) 인덱스
메모리 문제가 발생하고 앱이 다운됩니다.
위의 2 가지 루틴 내에서이 2 개의 스레드를 종료하는 것으로 실험되었지만 다른 문제가 발생합니다.
위의 2 개의 루틴이 MainThread에서 호출되어이 UIActivityIndicatorView를 사용하기 전에 모든 것이 좋습니다.
또한 MBProgressHud를 사용하여이 문제를 해결했으며 분명히 동일한 문제가 있습니다.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Loading";
HUD.detailsLabelText = @"plot data";
HUD.square = YES;
[HUD showWhileExecuting:@selector(DoMakeupPlot) onTarget:self withObject:nil animated:YES];
}
어떻게, 재정 번호를 수행하는 스레드를 제거 않는 MainThread가 수행하는 동안 UIActivityIndicatorView,이 설정을 완료 한 후?
감사합니다.
감사합니다. 다음 단계는 활동 표시기가 완료된 후 데이터 소스 및 위임을 설정하는 것입니다. – swainwri