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

时间:2012-05-28 11:58:21

标签: ios segue

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

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

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

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

有什么想法吗?

UPDATE:

我从我的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];

}

2 个答案:

答案 0 :(得分:2)

BannerView.h

@property (strong,nonatomic) IBOutlet id  delegate;

BannerView.m

[self.delegate callPerformSegue];

CategoryViewController.m

bannerView.delegate = self;

答案 1 :(得分:1)

你可能将Segue连接到TableView单元而不是ViewController。我养成了将Segues连接到VC而不是Buttons或TableView Cells的习惯。要解决此问题,请删除您现在拥有的Segue,然后将其重新连接到VC而不是TableView Cell。确保将其命名为相同。

相关问题