Saturday, 1 June 2013

How to create UIAlert View: cocos2d/Xcode


Syntax:

    [self Alertfunction];   // Call Alertfunction


    -(void)Alertfunction {
       
        UIAlertView* dialog = [[UIAlertView alloc] init];
        [dialog setDelegate:self];
        [dialog setTitle:@"Title"];
        [dialog setMessage:@"Do you want to play again?"];
        [dialog addButtonWithTitle:@"Yes"];
        [dialog addButtonWithTitle:@"No"];
        [dialog show];
        [dialog release];
    }


    - (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
        {
            if(buttonIndex==0) {
                //do stuff for first button click
            }
            else
                //do stuff for second button click
            }
        }

No comments:

Post a Comment