如何从此IBAction调用以下方法?

时间:2012-04-30 10:48:21

标签: objective-c ios5 methods ibaction

如何从此IBAction调用以下方法?我想调用prepareForSegue:方法而不是NSLog(@“clicked”);

这是IBAction:

- (IBAction) annotationViewClick:(id) sender {
    NSLog(@"clicked");
}

以下是方法:

// Do some customisation of our new view when a table item has been selected
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure we're referring to the correct segue
    if ([[segue identifier] isEqualToString:@"ShowMoreInfo"]) {

        // Get reference to the destination view controller
        MoreDetailViewController *mdvc = [segue destinationViewController];


        [mdvc setSelectedItemName:[NSString stringWithFormat:@"%@", placeName.text]];
        [mdvc setSelectedItemAddress:[NSString stringWithFormat:@"%@", placeFormattedAddress.text]];

        [mdvc setSelectedItemWeb:[NSString stringWithFormat:@"%@", placeWebsite.text]];
        [mdvc setSelectedItemRating:[NSString stringWithFormat:@"%@", placeRating.text]];
  //      [mdvc setSelectedItemDistance:[NSString stringWithFormat:@"%@", placeDistance.text]];

    }
}

感谢您的帮助!

2 个答案:

答案 0 :(得分:1)

执行segue时,

prepareForSegue:方法会自动调用。

要执行segue,您应该使用performSegueWithIdentifier:, 对于前[self performSegueWithIdentifier:@"showGuide" sender:self];

在这种情况下,您需要在Xcode Interface Builder中为segue分配标识符。

答案 1 :(得分:0)

尝试类似

的内容
UIStoryBoardSegue *segue = ... setup the one you want
[self performSelector:@selector(prepareForSegue:) withObject:seque afterDelay:0];

我从未使用过故事板 - 但这就是你如何称呼选择器:)