我在我的應用雙視圖控制器,一個控制器捕捉使用AVCapturSession的iOS的UIImageView不顯示圖像
我寫這一張照片,
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
CFDictionaryRef exifAttachments = CMGetAttachment(imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
if (exifAttachments)
{
// Do something with the attachments.
NSLog(@"attachements: %@", exifAttachments);
}
else
NSLog(@"no attachments");
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *displayimage = [[UIImage alloc] initWithData:imageData];
SecondViewController *sec = [[SecondViewController alloc]init];
sec.showTakenPic.image = displayimage;
[self.navigationController pushViewController:sec animated:YES];
}];
的SecondViewController包含一個UIImageView其圖像I我設置爲顯示圖像,但圖像未設置。
我SecondViewController從故事板製作,
的SecondViewController.h看起來是這樣的,
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
@property(atomic,retain) IBOutlet UIImageView *showTakenPic;
@end
的SecondViewController.m看起來是這樣的,
#import "SecondViewController.h"
@interface SecondViewController()
@end
@implementation SecondViewController
-(void)viewDidLoad {
[super viewDidLoad];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
-(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
該圖像是不可見的在UIImageView中爲什麼?
@安布。Karthik先生,showTakenPic是IBOutlet,他必須從故事板強制加載 – techloverr
我同意你的觀點,也認爲這種情況下,'imageData'轉換頁面之前導航也不會出現圖像 –
我的SecondViewController不是一個導航控制器,所以我可以像這樣推動它? –