XCODE2010.11.06 21:11
[아이폰 앱 개발] cancel alert

// Show an alert if "Appleseed" is not in Contacts

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 

message:@"Could not find Appleseed in the Contacts application" 
  delegate:nil 
  cancelButtonTitle:@"Cancel" 
  otherButtonTitles:nil];

[alert show];

[alert release];

Posted by 오늘마감
[아이폰 앱 개발] user와 인터렉션하는 alert 샘플
<form name="search" action="http://www.idev101.com/search.html" method="POST">

UIAlertView

</form>

Alert views are pop-up views that appear over the current view on the iPhone.

Creating and showing an alert:

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"Do you really want to reset this game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] autorelease]; // optional - add more buttons: [alert addButtonWithTitle:@"Yes"]; [alert show];

If you add the UIAlertViewDelegate protocol to your controller, you can also add the following method which is called after the user dismisses the alert view:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { // do stuff } }

Button indices start at 0 (for the cancelButton specified in the alloc/init), and go up by 1 for each addButtonWithTitle call you add. If you have a lot of alerts, your didDismiss method can keep track of which one is being dismissed if you add the setTag call to the alert initialization: [alert setTag:23];

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:@"I'm sorry Dave, I'm afraid I can't do that." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease]; [alert setTag:12]; [alert show]; ... later ... - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if ([alertView tag] == 12) { // it's the Error alert if (buttonIndex == 0) { // and they clicked OK. // do stuff } } }
Posted by 오늘마감
cancel alert

// Show an alert if "Appleseed" is not in Contacts

UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"Error"

message:@"Could not find Appleseed in the Contacts application"
  delegate:nil 
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];

[alert show];

[alert release];

Posted by 오늘마감
TAG alert, cancel
user와 인터렉션하는 alert 샘플
<form name="search" action="http://www.idev101.com/search.html" method="POST">

UIAlertView

</form>

Alert views are pop-up views that appear over the current view on the iPhone.

Creating and showing an alert:

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"Do you really want to reset this game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] autorelease]; // optional - add more buttons: [alert addButtonWithTitle:@"Yes"]; [alert show];

If you add the UIAlertViewDelegate protocol to your controller, you can also add the following method which is called after the user dismisses the alert view:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { // do stuff } }

Button indices start at 0 (for the cancelButton specified in the alloc/init), and go up by 1 for each addButtonWithTitle call you add. If you have a lot of alerts, your didDismiss method can keep track of which one is being dismissed if you add the setTag call to the alert initialization: [alert setTag:23];

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:@"I'm sorry Dave, I'm afraid I can't do that." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease]; [alert setTag:12]; [alert show]; ... later ... - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if ([alertView tag] == 12) { // it's the Error alert if (buttonIndex == 0) { // and they clicked OK. // do stuff } } }
Posted by 오늘마감
alert with 2buttons

Alert View and Url

May 9, 2010 1:30 AM


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]]; } -(void)awakeFromNib {         UIAlertView *baseAlert = [[UIAlertView alloc]                               initWithTitle:@"Url" message:@"Do you want to go to this website ?"                               delegate:self cancelButtonTitle:@"Yes"                               otherButtonTitles: @"No", nil];     [baseAlert self];     [baseAlert show];     [baseAlert release]; } 
Hello,
The Alert have Two buttons,
when the customer touch yes he must go to the website
but my problem is that know if he touch "no" he still go to the url
thanks for your help
In response to valicoldoklyne on May 10, 2010 3:41 PM

If your second button cancels the UIAlert View, the declaration of the Alert View needs to look like this.

UIAlertView *endAlert = [[UIAlertView alloc]
                                   initWithTitle:@"Game Over"
                                   message:@"This is the message"
                                   delegate:self
                                   cancelButtonTitle:@"Cancel"
                                   otherButtonTitles:@"Go to Apple's website", nil];

or if the second button performs a function,

UIAlertView *endAlert = [[UIAlertView alloc]
                                   initWithTitle:@"Game Over"
                                   message:@"This is the message"
                                   delegate:self
                                   cancelButtonTitle:nil
                                   otherButtonTitles:@"Restart", @"Go to Apple's website", nil];

and the void should be

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {

           //Restart Code


    }
    if (buttonIndex == 1) {

            //Go to Apple's website

   }
    
}

In response to Thomas Messner on May 10, 2010 4:08 PM

Just one suggestion, you might want to use cancelButtonIndex and strings, rather than those index constants:

    if (buttonIndex == alertView.cancelButtonIndex) {

        ......

    } else {

      NSString* l = [alertView buttonTitleAtIndex: buttonIndex];

      if ([l isEqualToString:@"xxxxx"]) {


etc.

This is more robust if you re-order the buttons, or if the indexes change (for example the actionSheet on the iPad doesn't have a cancel button).

Posted by 오늘마감
alert (UIAlertView) 를 보여주는 방법

by alex 13. 2월 2009 16:03

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

 if (buttonIndex == 1) {

  //OK clicked

 } else {

 }

}

- (void) _showAlert:(NSString*)title

{

 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:@"Check your networking configuration." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

 [alertView show];

 [alertView release];

}



출처 : http://blog.naver.com/PostView.nhn?blogId=amoros21&logNo=140107111371
Posted by 오늘마감