2012-03-13 2 views
0

여러 개의 viewController가있는 앱을 개발 중입니다. 첫 번째 것은 "MainMenu"이고 두 번째 것은 "Page1"입니다.Objective-c : 다음 페이지로 이동하면 "기다려주십시오"라는 메시지가 표시됩니다.

다음 페이지로 이동할 때 "기다려주십시오 ..."라는 경고가 표시됩니다. 아래 코드가 작동하지만 "page1"로드 된 후 경고가 나타납니다. 사용자가 "MainMenu"페이지에서 버튼을 누르면 나타납니다.

이 작업을 수행하기위한 제안이 있으십니까? 사전에

감사합니다.

AppDelegate.m

-(void)showAlert{ 
altpleasewait = [[UIAlertView alloc] initWithTitle:@"Please Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil]; 

[altpleasewait show]; 

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 

indicator.center = CGPointMake(altpleasewait.bounds.size.width/2, altpleasewait.bounds.size.height - 50); 
[indicator startAnimating]; 
[altpleasewait addSubview:indicator];  
} 


-(void)waitASecond{ 
[self performSelector:@selector(dismissAlert) withObject:self afterDelay:0.8];  

} 
-(void)dismissAlert{ 

[altpleasewait dismissWithClickedButtonIndex:0 animated:YES]; 

} 

MainMenu.m

-(void)gotoNextPage{ 

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; 
[appDelegate showAlert]; 
page1 = [self.storyboard instantiateViewControllerWithIdentifier:@"Page1"]; 
[self presentModalViewController:page1 animated:NO]; 

} 

Page1.m IBAction를에 경고를 넣어 당신이 할 수

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; 

-------------some methods-------------- 

[appDelegate waitASecond]; 
+1

당신은 MBProgressHUD을 시도해야합니다 : https://github.com/jdg/MBProgressHUD –

+0

내가 두 번째 것을, 완벽하게 작동 – basvk

+0

와우 좋은 하나입니다. 나는 나중에 이것을 시도 할 것이다. – user973067

답변

1

이것은 단지 제안에 불과합니다. 나는 다음을 할 것이다.

  1. -viewDidAppear의 Page1.m에서 나는 경고보기를 팝업으로 표시합니다. 이것은 주 스레드에서 발생합니다. 그래서 나는 UI가 표시되거나 반응하지 못하도록 막지 않을 것입니다.

  2. 나는 Page1 콘텐츠를로드하는 것과 관련된 모든 메소드를 이동합니다. URL에서 읽어 들여 블록에 넣고 GCD를 사용하여 백그라운드에서 발생하고 주 스레드를 차단하지 못하도록하는 텍스트 내가 그들을 데리고 UI를 업데이트하고 경고보기를 닫 것이다

    1. 로딩이 완료되면

    ....

여기에 간단한 아이디어가 있습니다. http://www.raywenderlich.com/4295/multithreading-and-grand-central-dispatch-on-ios-for-beginners-tutorial

+0

고마워요. 이거 간단히 작동합니다 !! – user973067

1

. 경고를 취소 한 다음보기를 변경하십시오. 또는 NSTimer를 사용하고 해당 타이머에 선택기를 할당하고 해당 선택기를 구현하여보기를 변경하십시오.

관련 문제