iOS,如何在UIAlertView中调用IBAction?

时间:2014-02-24 09:35:44

标签: ios uialertview ibaction

当用户点击"是"我想称之为IBAction在UIAlertView,我有:

- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (alertView.tag == 12) {
        if (buttonIndex == 1) {
            // How can I post IBAction here ???
            [self performSegueWithIdentifier:@"segue_to_call" sender:self];
        }
    }
}

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

假设您的IBAction方法是:

-(IBAction) sliderValue:(id)sender
{
   // SOME CODE
}

你可以这样调用这个方法

-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(alertView.tag == 200){

        if (buttonIndex==1) {           
        [self sliderValue:nil]; //Here is your IBAction Method          
        [self performSegueWithIdentifier:@"segue_to_call" sender:self];
       }
    }

 }

答案 1 :(得分:0)

使用此

 -(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
       if (alertView.tag == 12) {
        if (buttonIndex == 1) {
            [self methodName:nil];
        }
    }
}

-IBAction) methodName {
    NSLog(@"Method run in this");
}