我想出現在用「ViewController」拍攝的「PreviewViewController」圖片的「UIImageView」中。UIImagePickerController圖像,顯示到另一個類
但我不能。
請告訴我
ViewController.m
-(void)imagePickerController:(UIImagePickerController *)pic didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[imagePicker dismissViewControllerAnimated:YES completion:NO];
UIImage *originalImage;
originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
CGSize size = { 100, 200 };
UIGraphicsBeginImageContext(size);
CGRect rect;
rect.origin = CGPointZero;
rect.size = size;
[originalImage drawInRect:rect];
UIImage* shrinkedImage;
shrinkedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect r = CGRectMake(0, 60, 100, 100);
CGImageRef cgImage = CGImageCreateWithImageInRect(shrinkedImage.CGImage, r);
iconImage = [UIImage imageWithCGImage:cgImage];
UIImageWriteToSavedPhotosAlbum (iconImage, nil, nil , nil);
// This problem!!!
PreviewViewController *p = [[PreviewViewController alloc] init];
p.imagePreview.image = iconImage;
[self presentViewController:p animated:YES completion:NO];
}
PreviewViewController.h
@property (nonatomic) UIImageView *imagePreview;
我不使用XIB和StoryBoard.Have是否創建了一個可以接收iconImage的UIImageView?>你是什麼意思? – onion
我想將UIimageViewmade(imagePreview)放到另一個類(PreviewViewController)中。 我製作了PreviewViewController的imagePreview。 – onion
@onion在你的類中:PreviewViewController是你在'init'中做了這樣的事情:'[[UIImageView alloc] initWithFrame];'? –