我的代碼發生了一些奇怪的事情。從相機傳遞圖像以查看故事板
場景:!打開照相機 - >拍攝圖像 - >傳遞帶到一個視圖 - 控制圖像(從故事板
的事情是,從目標視圖我的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 *'
爲什麼雖然在目的地的.h文件中聲明cameraImage
不能從起源的看法?
在另一種情況,其中i需要通過視圖之間的串,在與上述同樣地
[yourViewController setValue:mysc.title forKey:@"sendAlertTitle"];
工作確定。
任何幫助?
謝謝。
? –
我想我解釋過。從View1按下一個按鈕,打開攝像頭,拍攝圖片,通過圖片查看2. – Theodoros80
http://stackoverflow.com/questions/20858693/access-data-variable-from-one-class-in-another-class/20858773 #20858773 –