您好我正在开发一个iPhone应用程序。我正在触发segue和内部onprepare segue我正在向我的下一个视图控制器发送数据。在故事板中,我的segue指向我期望的视图控制器的导航控制器及其后面的segue。所以这是我的问题:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"mediaDetailSegue1"] || [[segue identifier] isEqualToString:@"mediaDetailSegue2"])
{
// this is working properly on below IOS 8 but not on IOS8
MediaDetailViewController *mediaDetail = [segue destinationViewController];
// this is working properly on IOS8 but not on below versions.
MediaDetailViewController *mediaDetail = ([[segue destinationViewController]viewControllers][0]);
mediaDetail.videoData = [_mediaContentArray objectAtIndex:selectedIndex];
mediaDetail.isPlayVideo = isPlayVideo;
}
}
因此,正如我在上面提到的那样,目标控制器对两个版本都没有正常工作。它给了我以下错误:
for IOS8
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setVideoData:]: unrecognized selector sent to instance 0x176aa980'
for below IOS7
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MediaDetailViewController viewControllers]: unrecognized selector sent to instance 0x14de8c00'
我可以根据版本处理这种情况,但我想知道我是做对还是错。处理这种情况的正确方法是什么?需要一些帮助。谢谢。