1

如何从此 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]];

    }
}

谢谢您的帮助!

4

2 回答 2

1

prepareForSegue:执行 segue 时会自动调用方法。

要执行转场,您应该使用performSegueWithIdentifier:, 例如。[self performSegueWithIdentifier:@"showGuide" sender:self];,

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

于 2012-04-30T11:08:41.723 回答
0

我试试类似的东西

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

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

于 2012-04-30T10:51:50.303 回答