PyroTech
PyroTech

Reputation: 11

presentModalViewController with xib works, how do you do the same with Storyboards?

I can get this to work with xib's, but how do I achieve the same using Storyboards? I believe I need to use prepareForSegue, but not sure how to implement it. Here is my code:

- (void)buttonTouched:(id)sender {
// When picture is touched, open a viewcontroller with the image
PFObject *theObject = (PFObject *)[allImages objectAtIndex:[sender tag]];
PFFile *theImage = [theObject objectForKey:@"imageFile"];

NSData *imageData;
imageData = [theImage getData];
UIImage *selectedPhoto = [UIImage imageWithData:imageData];
PhotoDetailViewController *pdvc = [[PhotoDetailViewController alloc] init];

pdvc.selectedImage = selectedPhoto;
[self presentModalViewController:pdvc animated:YES];

}

Upvotes: 1

Views: 239

Answers (1)

Tom Fobear
Tom Fobear

Reputation: 6749

to manually create a viewcontroller defined in a storyboard, you must give it an identifier

viewController:

[self.storyBoard instantiateViewControllerWithIdentifier:(NSString *)indentifier];
[self.storyBoard instantiateInitialViewController];

will return a viewcontroller from a storyboard

Fixed thanks from @jere

Upvotes: 1

Related Questions