UIActivityIndicatorView가있는보기 컨트롤러와 동기화를 트리거하는 단추가 있습니다. 동기화는 일반적으로 백그라운드에서 별도의 클래스에서 수행됩니다. 동기화는 내 앱의 다른 부분에서 트리거 될 수 있으며 내 View Controller는 동기화 이벤트를 통보받습니다.UIActivityIndicatorView가 애니메이션 표시/시작되지 않습니다.
이제 버튼을 클릭하면 UIActivityIndicatorView가 표시되거나 애니메이션으로 표시되지 않습니다. 내가 시작하고 같은 방법으로 표시보기를 중지하면 UI이기 때문에, 그것은 작동하지 않습니다 것을, 나는 다른 게시물에 읽고
self.syncNowActivityIndicatorView.hidesWhenStopped = YES;
self.syncNowActivityIndicatorView.color = [MRStyleController getFirstLightColor];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(leechStarted)
name:MRLeechStartedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mergeStarted)
name:MRMergeStartedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(fileSyncStarted)
name:MRFileSyncStartedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(leechFailed)
name:MRLeechFailedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mergeFailed)
name:MRMergeFailedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(fileSyncFailed)
name:MRFileSyncFailedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(leechCompleted)
name:MRLeechCompletedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mergeCompleted)
name:MRMergeCompletedNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(fileSyncCompleted)
name:MRFileSyncCompletedNotification
object:nil];
: 여기
가있는 viewDidLoad 내 코드입니다 메서드가 실행되는 동안 업데이트되지 않습니다. 따라서 애니메이션은 별도의 스레드에서 시작되고 중지되어야하지만 제 경우에는 시작 및 중지 호출이 모두 다른 방법으로 이루어집니다.로그가 표시 될 때 알림을 받고 있습니다. 여기
-(void)leechStarted{
NSLog(@"Leech started");
if (!_syncNowActivityIndicatorView.isAnimating) {
[_syncNowActivityIndicatorView startAnimating];
}
}
-(void)mergeStarted{
NSLog(@"Merge started");
if (!_syncNowActivityIndicatorView.isAnimating) {
[_syncNowActivityIndicatorView startAnimating];
}
}
-(void)fileSyncStarted{
NSLog(@"FileSync started");
if (!_syncNowActivityIndicatorView.isAnimating) {
[_syncNowActivityIndicatorView startAnimating];
}
}
-(void)leechFailed{
NSLog(@"Leech failed");
if (_syncNowActivityIndicatorView.isAnimating) {
[_syncNowActivityIndicatorView stopAnimating];
}
}
-(void)mergeFailed{
NSLog(@"Merge failed");
if (_syncNowActivityIndicatorView.isAnimating) {
[_syncNowActivityIndicatorView stopAnimating];
}
}
-(void)fileSyncFailed{
NSLog(@"FileSync failed");
if (_syncNowActivityIndicatorView.isAnimating) {
[_syncNowActivityIndicatorView stopAnimating];
}
}
-(void)leechCompleted{
NSLog(@"Leech completed");
if (_syncNowActivityIndicatorView.isAnimating) {
[_syncNowActivityIndicatorView stopAnimating];
}
}
-(void)mergeCompleted{
NSLog(@"Merge completed");
if (_syncNowActivityIndicatorView.isAnimating) {
[_syncNowActivityIndicatorView stopAnimating];
}
}
-(void)fileSyncCompleted{
NSLog(@"FileSync completed");
if (_syncNowActivityIndicatorView.isAnimating) {
[_syncNowActivityIndicatorView stopAnimating];
}
}
그리고 버튼의 IBAction를 : 여기에
은 다른 방법이 있습니다- (IBAction)syncNow:(id)sender {
// perform synchronisation
CoreDataHelper *cdh = [(MRMedSafeAppDelegate *) [[UIApplication sharedApplication] delegate] cdh];
if ([cdh canSynchronize]) {
[cdh mergeEnsemble];
[cdh synchroniseFiles];
}
}
mergeEnsemble
게시물 거머리 및 알림을 병합하고, synchroniseFiles
파일 동기화 알림, 나는 그들을 따라 수신 로그에.
하지만 동기화가 너무 빨리 발생하기 때문에 그게 내가조차 표시되지 않는 것이, 아마 표시기 렌더링. 다음 번에 더 큰 동기화가 발생하면 그것이 보이고 애니메이션이되는지 확인해야합니다. 그러나 나는 네가 옳다고 생각하니 너의 대답을 받아 들인다. – mrd