'아이폰 로딩 창'에 해당되는 글 2건

  1. 2010.07.21 UIAlertView without Buttons - Please Wait Dialog
  2. 2010.07.21 MBProgressHUD
원본: http://iphonedevelopertips.com/user-interface/uialertview-without-buttons-please-wait-dialog.html
출처: http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=7462&MAEULNO=911&no=52368&page=1

If you’ve ever wanted to show a simple “please wait” dialog without resorting to a custom view, UIAlertView is a good option, and is even more appropriate if you customize the alert such that no buttons are shown.

In the figure below you can see how a simple alert can be shown (sans buttons) while you are busy doing some other system activity (reading/writing files, etc).


UIAlertView without Buttons
UIAlertView *alert;
 
...
 
alert = [[[UIAlertView alloc] initWithTitle:@"Configuring Preferences\nPlease Wait..." 
  message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
 
[alert show];

Trouble with this approach is that things look a little lopsided, as there is a significant amount of dead space on the bottom where the button(s) are to be shown. We can fix this by adding a few newline characters at the start of our message:

UIAlertView *alert;
 
...
 
// Add two newlines characters at the start of the message
alert = [[[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait..." 
  message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
 
[alert show];

The text is nearly centered, yet we’ve created a different problem, there is now white space on the top and bottom. There is one more approach…

UIAlertView with UIActivity Indicator

In the whitespace on the bottom, let’s add an activity indicator. Also, remove the newlines in the message text so the text starts near the top:

UIAlertView *alert;
 
...
 
alert = [[[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait..." 
  message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];

[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];
[indicator release];

Dismissing the Buttonless UIAlertView

Since there are no buttons associated with the alert, we have to dismiss the alert ourselves, versus the traditional approach where the system dismisses the alert when a button is pressed.

Here is the call to dismiss the alert:

[alert dismissWithClickedButtonIndex:0 animated:YES];

'iOS > Skills' 카테고리의 다른 글

모달 뷰 사용(일종의 팝업 윈도우)  (1) 2010.11.23
애니메이션 주기  (0) 2010.11.10
MBProgressHUD  (0) 2010.07.21
UIBarButtonSystemItem 추가된 아이템  (0) 2010.07.21
UIAlertView 커스터마이징  (0) 2010.07.21
Posted by 독뽀
,

MBProgressHUD

iOS/Skills 2010. 7. 21. 19:54

원본: http://github.com/jdg/MBProgressHUD
출처: http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=7462&MAEULNO=911&no=52297&page=1


MBProgressHUD

MBProgressHUD is an iPhone drop-in class that displays a translucent HUD with a progress indicator and some optional labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD with some additional features.

 

Adding MBProgressHUD to your project

The simplest way to add the MBProgressHUD to your project is to directly add the MBProgressHUD.h and MBProgressHUD.m source files to your project.

  1. Download the latest code version from the repository (you can simply use the Download Source button and get the zip or tar archive of the master branch).
  2. Extract the archive.
  3. Open your project in Xcode, than drag and drop MBProgressHUD.h and MBProgressHUD.m to your classes group (in the Groups & Files view).
  4. Make sure to select Copy items when asked.

Usage

A full Xcode demo project is included in the Demo directory. This should give you an idea how to use the class.

Posted by 독뽀
,