我有一个带有四个标签的tabBar应用。每个标签页的左侧都有一个相机按钮UINavigationBar
。单击相机按钮,进入相机模式,拍摄照片,最后选择“使用照片”后,应将照片传输到另一个ViewController并放置在UIImageView
中,该attachButtonInvoked
仅在名为{{的方法后显示1}}被触发。这是我的方法,请忽略注释行:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//UIImage * image = [info objectForKey:UIImagePickerControllerEditedImage];
//[picker dismissViewControllerAnimated:NO completion:nil];
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
//UIImageWriteToSavedPhotosAlbum(image,nil,nil,nil);
RGPostTableViewController *postTableView = [self.storyboard instantiateViewControllerWithIdentifier:@"postTableView"];
RGPostViewController *postView = [self.storyboard instantiateViewControllerWithIdentifier:@"postView"];
UINavigationController *postControl = [self.storyboard instantiateViewControllerWithIdentifier:@"postControl"];
//postView.postImageView.image = image;
//[picker dismissViewControllerAnimated:NO completion:nil];
[picker presentViewController:postControl animated:YES completion:nil];
NSLog(@"%@", image);
[postTableView attachButtonInvoked];
postView.postImageView.image = image;
}
到目前为止,我正在获取图像。但我无法成功拨打attachButtonInvoked
;它没有透露UIImageView并设置图片。
答案 0 :(得分:2)
看起来你可能在这里实例化新的视图控制器
RGPostTableViewController *postTableView = [self.storyboard instantiateViewControllerWithIdentifier:@"postTableView"];
RGPostViewController *postView = [self.storyboard instantiateViewControllerWithIdentifier:@"postView"];
UINavigationController *postControl = [self.storyboard instantiateViewControllerWithIdentifier:@"postControl"];
而不是使用已经创建过的那个。相反,尝试获取对已经实例化的视图控制器的引用,以便您可以在图像视图上设置图像。