1

我可以让它与 xib 一起使用,但是如何使用 Storyboards 实现相同的效果?我相信我需要使用 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];

}

4

1 回答 1

1

要手动创建在故事板中定义的视图控制器,您必须给它一个标识符

视图控制器:

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

将从情节提要中返回一个视图控制器

修复了来自@jere 的感谢

于 2012-08-30T21:42:35.190 回答