ios - 'NSInvalidArgumentException',原因 : 'Receiver (**) has no segue with identifier ' * *''

标签 ios segue

我真的希望以前没有人问过这个问题。我在这个网站上花了很多时间寻找解决方案,但一直没能想出一个。我正在尝试从名为 callPerformSegue 的函数中调用 performSegueWithIdentifier。单击 UITableView 部分页脚中的 UIImageView 时调用 callPerformSegue。 callPerformSegue 函数如下:

- (void)callPerformSegue {
    [self performSegueWithIdentifier:@"bannerPressed" sender:self];
} 

我在 Storyboard 中正确识别了 bannerPressed segue,因为如果我将 performSegueWithIdentifier 调用移动到 didSelectRowAtIndexPath 中,segue 就会正确执行。但是,当从 callPerformSegue 调用时,我得到以下信息:

'NSInvalidArgumentException', 原因:'接收者 (****) 没有标识符为'bannerPressed'的segue'

有什么想法吗?

更新:

我从我的 BannerView 类调用函数 callPerformSegue,它是 UIImageView 的子类。当有人点击横幅时,此类会处理触摸事件,并确定在收到触摸时显示的图像。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    //Get the time of the click
    NSDate *animationStart;
    NSDate *clickTime;
    clickTime = [NSDate date];

    NSMutableArray *bannerArrayFromDictionary = [self.bannerDictionary objectForKey:[NSNumber numberWithInt:self.currentSection]];

    //Calculate the time elapsed since animationStart and clickTime
    animationStart = [bannerArrayFromDictionary objectAtIndex:0];

    int secondsElapsed = [clickTime timeIntervalSinceDate:animationStart];

    //Determine the number of elements for the section
    int numberOfImagesForSection = [bannerArrayFromDictionary count] - 1;

    //Determine the index into the animationArrary
    int imageClickedIndex = (secondsElapsed / 5) % numberOfImagesForSection;

    //Add 1 to the index to compensate for the timestamp
    imageClickedIndex++;

    //Get the image name
    NSString *clickedImage = [bannerArrayFromDictionary objectAtIndex:imageClickedIndex];

    //Set the image name in CategoryViewController so that a segue to the Detail Page can be performed
    CategoryViewController *view = [[CategoryViewController alloc] init];
    view.currentImage = clickedImage;
    [view callPerformSegue];

}

最佳答案

横幅 View .h

@property (strong,nonatomic) IBOutlet id  delegate;

BannerView.m

[self.delegate callPerformSegue];

CategoryViewController.m

bannerView.delegate = self;

关于ios - 'NSInvalidArgumentException',原因 : 'Receiver (**) has no segue with identifier ' * *'' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10784302/

相关文章:

ios - SWIFT:如何使用不同类的performSegueWithIdentifier

ios - 创建一个 segue 并通过 Swift 将其附加在两个 View Controller 之间?

ios - 从另一个 UIViewController 执行 Segue

ios - Firestore 离线未更新

iphone - iOS 4.3 分发二进制文件不再适用于 iPhone 3G/第二代 iPod Touch?

swift - 当尝试在 2 个 Controller 之间传递数据时,出现错误无法将类型 'ViewController.Item?' 的值分配给类型 'Item?' ,

ios - 如何在不看到第一个的情况下以模态方式推送两个 View Controller

ios - sendAction :to:from:forEvent:? 的用法

ios - 如何在不使用 TableViewController 的情况下创建分组 TableView

ios 快速检测悬停在 uiview 上的时间