我正在使用故事板,我需要使用子視圖來導入xib。 xib只是顯示圖像。它有一個UIImageView和一個UIBarButtonItem。將圖像導入爲子視圖後,如何設置圖像?如何使用instantiateViewControllerWithIdentifier調用視圖控制器來設置UIImageView?
我試過在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’」