我真的希望以前没有人问过这个问题。我在这个网站上花了很多时间寻找解决方案,但一直没有想出一个解决方案。我正在尝试从名为 callPerformSegue 的函数中调用 performSegueWithIdentifier。当单击 UITableView 中某个部分的页脚中的 UIImageView 时,将调用 callPerformSegue。callPerformSegue 函数如下:
- (void)callPerformSegue {
[self performSegueWithIdentifier:@"bannerPressed" sender:self];
}
我在情节提要中正确识别了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];
}