使用xib的presentModalViewController工作,你如何使用Storyboard做同样的事情?

时间:2012-08-30 21:38:18

标签: ios presentmodalviewcontroller

我可以使用xib来实现这一点,但如何使用Storyboard实现相同目的?我相信我需要使用prepareForSegue,但不知道如何实现它。这是我的代码:

- (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];

}

1 个答案:

答案 0 :(得分:1)

要手动创建在故事板中定义的viewcontroller,您必须为其指定标识符

viewController:

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

将从故事板中返回一个viewcontroller

已修复感谢@jere