【发布时间】:2014-01-17 13:36:41
【问题描述】:
我的代码发生了一些奇怪的事情。
场景:打开相机->拍照->将拍摄的图像传递给视图控制器(来自情节提要。
问题是我的目标视图中的 UIimage 变量不可用,无法识别!
我的代码
postviewController.h
#import <UIKit/UIKit.h>
@interface postAlertViewController : UIViewController
@property (nonatomic, retain) UIImage *cameraImage;
@end
postviewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
UIImageView *aImageview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 60, self.view.frame.size.width,150 )];
aImageview.image=cameraImage;
[self.view addSubview:amageview];
}
拍照并传递给上面的视图控制器
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissViewControllerAnimated:YES completion:NULL];
ViewController *postView = [self.storyboard instantiateViewControllerWithIdentifier:@"postview"];
postView.cameraImage=(UIImage *)[info objectForKey:UIImagePickerControllerEditedImage];
[self.navigationController pushViewController:postView animated:YES];
}
故事板 ID 设置为“postview”。 我得到的是:
Property 'cameraImage' not found on object of type 'ViewController *'
为什么cameraImage 在目标的 .h 文件中声明,但在源视图中不可用?
在另一种情况下,我需要在视图之间传递字符串,方式与上面相同
[yourViewController setValue:mysc.title forKey:@"sendAlertTitle"];
工作正常。
有什么帮助吗?
谢谢。
【问题讨论】:
-
您想在其他视图控制器中显示您的图像吗?
-
我想我已经解释过了。从 View1 按下按钮,打开相机,拍照,将图片传递给 View 2。
-
在你的情况下 secondViewController.imageview.image = firstimageview.image;
标签: ios objective-c storyboard