私は本当にこれが前に尋ねられなかったことを望みます。私はこのサイトで解決策を探すのにかなりの時間を費やしましたが、解決策を思い付くことができませんでした。callPerformSegueという関数からperformSegueWithIdentifierを呼び出そうとしています。callPerformSegueは、UITableViewのセクションのフッターにあるUIImageViewがクリックされたときに呼び出されます。callPerformSegue関数は次のとおりです。
- (void)callPerformSegue {
[self performSegueWithIdentifier:@"bannerPressed" sender:self];
}
ストーリーボードでbannerPressedセグエが正しく識別されています。これは、performSegueWithIdentifier呼び出しをdidSelectRowAtIndexPathに移動すると、セグエが正しく実行されるためです。ただし、callPerformSegueから呼び出されると、次のようになります。
'NSInvalidArgumentException'、理由:'受信者(****)に識別子'bannerPressed''のセグがありません
何か案は?
アップデート:
UIImageViewのサブクラスであるBannerViewクラスから関数callPerformSegueを呼び出します。このクラスは、誰かがバナーをクリックしたときのタッチイベントを処理し、タッチが受信されたときに表示された画像を判別します。
- (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];
}