我在我的应用双视图控制器,一个控制器捕捉使用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不是一个导航控制器,所以我可以像这样推动它? –