Iphone 如何从使用InstanceViewController WithiIdentifier调用的视图控制器设置UIImageView?

Iphone 如何从使用InstanceViewController WithiIdentifier调用的视图控制器设置UIImageView?,iphone,objective-c,xcode,ios5,Iphone,Objective C,Xcode,Ios5,我正在使用故事板,我需要使用子视图来导入xib。xib只是显示一个图像。它有一个UIImageView和一个UIBarbuttonite。将图像导入为子视图后,如何设置图像 我曾尝试在h+m文件中为子视图xib设置方法,但可能我做得不对。这是我的密码 -(void)showPreviewImageScreen:(UIImage *)image { UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard

我正在使用故事板,我需要使用子视图来导入xib。xib只是显示一个图像。它有一个UIImageView和一个UIBarbuttonite。将图像导入为子视图后,如何设置图像

我曾尝试在h+m文件中为子视图xib设置方法,但可能我做得不对。这是我的密码

-(void)showPreviewImageScreen:(UIImage *)image 
{

    UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"libraryImagePreview"];

    [vc setPreviewImage:image];

    [self.navigationController.view addSubview:vc.view];

}

我得到的错误是“没有UIViewController的可见@interface声明选择器‘setPreviewImage’”

据我所知,没有称为setPreviewImage的方法。您使用setImage设置了图像:但必须在xib中的UIImageView上调用,而不是在视图控制器vc上调用。谢谢您为我指明了正确的方向。。这就是我想出的解决办法。。 我用1标记UIimageView,然后在子视图中循环找到这个标记并以这种方式定位它

-(void)showPreviewImageScreen:(UIImage *)image 
{

    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"libraryImagePreview"];


    for (UIView *subview in vc.view.subviews)
    {
        if(subview.tag==1)
        {
            UIImageView *IV = subview;
            [IV setImage:image];
        }
    }

   [self.navigationController.view addSubview:vc.view];

}