On my app I decided to change my segue to a Show Details segue in the story board as I wanted the affect of the storyboard coming from the bottom of the screen, and thus I needed some way to bring the user back, so I inserted a navigation into the destination view. However now I get:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setImageData:]: unrecognized selector sent to instance 0x7fbdfa887600'
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"infoSegue"])
{
// Get reference to the destination view controller
DetailsViewController *vc = [segue destinationViewController];
// Pass any objects to the view controller here, like...
int num = (int)[self getIndexNum];
NSString *dictionaryKey = _results[num];
Image *image = _dataDictionary[dictionaryKey];
vc.imageData = image;
NSLog(@"Vendor ID %@",image.vendorId);
}
}
Has the navigation become the parent of the view or something?
if your destination view controller is a navigation controller, then you shouldn't set the image on navigation controller!! Also as @vadian from the answer said, you need to cast the return type of uiviewcontroller
!!!
UINavigationController *navController = [segue destinationViewController];
DetailsViewController *viewController = (DetailsViewController *)([navController viewControllers][0]);
[viewController setimageData:image];
Make sure imageData is of kind UIImage
. If it is of type NSData
, you might need to do:
[viewController setimageData:[UIImage imageWithData:imageData]];