如何使用 Segue
从库中添加图片并将图像从 MasterViewController 发送到 DetailViewController答案 0 :(得分:1)
查看本教程中的图像选择器: http://www.techotopia.com/index.php/Accessing_the_iOS_7_Camera_and_Photo_Library
按照您想要的方式打开它之后,您需要在UIImagePicker委托的此委托方法中调用您的segue:
-(void)imagePickerController:
(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
_image = info[UIImagePickerControllerOriginalImage];
[self performSegueWithIdentifier:@"MySegue" sender:sender];
}
在你的prepareForSeague中:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"MySegue"])
{
// Get reference to the destination view controller
YourViewController *vc = [segue destinationViewController];
// Pass any objects to the view controller here, like...
[vc setMyObjectHere:_image];
}
}
当然,您需要为故事板内的segue建立正确的连接。但我想你想要的是需要做的事情的大局。
我希望它有所帮助!