我真的希望以前没有人问过这个问题。我在这个网站上花了很多时间寻找解决方案,但一直没能想出一个。我正在尝试从名为 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/