iOS UIActionSheet

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Want to use UIActionSheet to add a protocol now in the.H file  

<UIActionSheetDelegate>

When the operating table

//Defines an operation table
- (IBAction)uisheel:(id)sender {
    UIActionSheet *action=[[UIActionSheet alloc] initWithTitle:@"who!!!" delegate:self cancelButtonTitle:@"yes" destructiveButtonTitle:@"no" otherButtonTitles:@"yes or no", nil];
    
    [action showInView:self.view];
    [action release];
}



//The first calls from one event operation list

- (void)actionSheetCancel:(UIActionSheet *)actionSheet
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"actionSheetCancel1 you" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];//The statement of operation table
    [v show];//Perform the operation table
    [v release];//Release operation table
}

// Called when a button is clicked. The view will be automatically dismissed after this call returns
//Start but we click operation table button events
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    //ButtonIndex judgment when we click that button, we set up in the first buttonIndex number 1, second, 2. . . 
    if (buttonIndex==0) {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"I am Number one" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    }
    else if (buttonIndex==1) {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"I am number Two" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    }
    else {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"I am number threeth" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    }

}

//Called when a button is clicked. The view will be automatically dismissed after this call returns
//Display view before calling
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet // before animation and showing view 1 7
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"The first and last" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
    [v show];
    [v release];

}
// Called when we cancel a view (eg. the user clicks the Home button)Is not called when. This the user clicks the cancel button. to cancel view call
// If not defined in the delegate, we simulate a click in the cancel button
//Display view after calling
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet;  // after animation 2 6
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"Second and sixth" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
    [v show];
    [v release];

}
//Before the animation and hide the view before calling
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex
// before animation and hiding view3 5
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"Third and fifth" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
    [v show];
    [v release];

}
//Animation after calling
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
// after animation 4
{
    UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"Fourth times" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
    [v show];
    [v release];

}




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Hyman at November 22, 2013 - 12:15 PM