Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 为什么我的图像没有被传递到我的ViewController?_Objective C_Uiimageview_Uiimage_Uiimagepickercontroller - Fatal编程技术网

Objective c 为什么我的图像没有被传递到我的ViewController?

Objective c 为什么我的图像没有被传递到我的ViewController?,objective-c,uiimageview,uiimage,uiimagepickercontroller,Objective C,Uiimageview,Uiimage,Uiimagepickercontroller,我已经设置了我的应用程序,以便有多个图像采集器,每个采集器都有自己的图像阵列。用户将按下要查看的设置,选择图像,然后应用程序将弹出回根控制器。我希望他们选择的图像作为子视图添加到我的主ViewController中 我在获取主ViewController以检测所选图像时遇到问题 以下是我如何尝试的: 在我的图像选择器中: 编辑我又有问题了。我添加了一个新的viewController,这样用户就可以选择他们想要查看的图像阵列,而不是直接进入图像阵列。我更改了弹出到viewController的方

我已经设置了我的应用程序,以便有多个图像采集器,每个采集器都有自己的图像阵列。用户将按下要查看的设置,选择图像,然后应用程序将弹出回根控制器。我希望他们选择的图像作为子视图添加到我的主ViewController中

我在获取主ViewController以检测所选图像时遇到问题

以下是我如何尝试的:

在我的图像选择器中:

编辑我又有问题了。我添加了一个新的viewController,这样用户就可以选择他们想要查看的图像阵列,而不是直接进入图像阵列。我更改了弹出到viewController的方式,因为我现在不返回RootViewController

- (IBAction)buttonClicked:(id)sender
{
    UIButton *button = (UIButton *)sender;
    _selectedImage = [_images objectAtIndex:button.tag];
    AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
    delegate.viewController.stampedImage = _selectedImage;
    NSLog(@"delegate.viewController = %@", delegate.viewController);
    NSLog(@"delegate.viewController.stampedImage = %@", delegate.viewController.stampedImage);
    NSLog(@"_selectedImage = %@", _selectedImage);
    [delegate.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
}
我在这里运行了一个NSLog,selectedImage被设置为一个映像

以下是我在主ViewController中所做的操作,我希望图像显示在主ViewController中。我正在VIEW中运行此代码将出现:

//stampedImage = _imagePicker.selectedImage;  --- Not sure if I need this line
_stampedImageView = [[UIImageView alloc] initWithImage:stampedImage];
NSLog(@"ViewController stampedImage = %@", stampedImage);
[_stampedImageView setFrame:CGRectMake(0, 0, 80.0, 80.0)];
[_stampedImageView setMultipleTouchEnabled:YES];
[_stampedImageView setUserInteractionEnabled:YES];
[imageView addSubview:_stampedImageView];
[_stampedImageView release];
我在这里运行了一个NSLog,但是stampedImage总是返回null。 stampedImage总是返回为null

我已将stampedImage设置为属性,正在合成。
我还为我的图像选取器类在.h中设置了一个@class


有什么想法吗?出于某种原因,我在这一点上被难住了。

说你运行了一个
NSLog
“这里”是毫无帮助的。请编辑您的代码以准确显示您正在执行的操作。我还注意到,如果我按下ViewController,新图像确实会被添加,但我用相机拍摄的图像不见了。如果我使用popToViewController,相机图像在那里,但所选图像不会被添加。