2014-11-25 3 views
5

Android 개발에서 ProgressDialog를 사용하여 '회전판', 일부 텍스트 및 취소 버튼이있는 대화 상자를 제공합니다. 사용자가 대화 상자를 취소하지 않으면이 작업을 CountdownTimer와 함께 사용하여 10 초 후에 작업을 수행합니다.iOS에서 Android ProgressDialog와 동일한 기능이 있습니까

나는 오픈 소스 SVProgressHUD 및 MBProgressHUD와 같은 iOS에서 이에 상응하는 항목을 검색했지만 아무 것도 단추 추가를 지원하지는 않습니다.

직접 작성해야하나요, 아니면 누구든지 쉬운 방법을 알고 있습니까? 코드 아래

+1

. 업데이트 된 답변을 보려면 [다음] (http://stackoverflow.com/a/25671652/6042879)을 따르십시오! –

+0

신속한 https://github.com/shubh10/JustHUD –

답변

7
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; 
indicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0); 
indicator.center = self.view.center;  
[self.view addSubview:indicator]; 
[indicator bringSubviewToFront:self.view]; 
[UIApplication sharedApplication].networkActivityIndicatorVisible = TRUE; 

쓰기 당신은 당신이 How to programmatically add a simple default loading(progress) bar in iphone app

UPD에서 발견 된 표시를

[indicator stopAnimating]; 

을 숨길 때 표시를 코드 아래

[indicator startAnimating]; 

쓰기를 표시 할 때 : 경고 대화 상자를 만들 수 있습니다. t 버튼과 수동으로 사용자 지정 요소를 추가

UIAlertView *alert; 

... 

alert = [[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil]; //display without any btns 
// alert = [[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait..." message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: nil]; //to display with cancel btn 
[alert show]; 

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

// Adjust the indicator so it is up a few pixels from the bottom of the alert 
indicator.center = CGPointMake(alert.bounds.size.width/2, alert.bounds.size.height - 50); 
[indicator startAnimating]; 
[alert addSubview:indicator]; 

이 경고를 닫으려면 단지에서

[alert dismissWithClickedButtonIndex:0 animated:YES]; 

더 많은 정보를 수행 http://iosdevelopertips.com/user-interface/uialertview-without-buttons-please-wait-dialog.html IOS 9.0 UIAlertView가 사용되지 않았기 때문에

+0

에서 iOS 용으로이 HUD 라이브러리를 사용해보십시오. 답변을 주셔서 감사합니다.하지만 나중에 취소 할 수있는 회전 표시가 있지만 취소 버튼 옵션은 제공하지 않습니다. –

+0

새로운 접근 방식으로 대답이 업데이트되었습니다 –

+0

취소 버튼을 표시하려면 다음과 같이 변경해야합니다. alert = [[UIAlertView alloc] initWithTitle : @ "\ n \ n 환경 설정 \ n 기다려주십시오 ..."메시지 : nil delegate : self cancelButtonTitle : @ "Cancel"otherButtonTitles : nil]; –

관련 문제