あるビューから別のビューに画像を渡そうとしています。カメラボタンがあり、押すとuiimagepickercontrollerが起動します。画像を選択すると、写真の編集画面が画面に表示されます。画面が読み込まれるたびに何も表示されません。この投稿Passing image from one view to anotherに従ってみましたが、うまくいかないようです。
最初のView Controllerのコードは次のとおりです。
firstViewController.h
@interface firstViewController : UITableViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate>
- (IBAction)cameraButtonPressed:(id)sender;
firstViewController.m
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissViewControllerAnimated:YES completion:^{
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
ECDEditViewController *viewController = [[ECDEditViewController alloc] initWithImage:image];
UINavigationController *composeController = [self.storyboard instantiateViewControllerWithIdentifier:@"showCompose"];
//[self.navigationController presentViewController:composeController animated:YES completion:nil];
[self.navigationController pushViewController:composeController animated:YES];
}];
}
secondViewController.h
@interface ECDEditViewController : UITableViewController <UIImagePickerControllerDelegate>
- (id)initWithImage:(UIImage *)aImage;
@property (strong, nonatomic) IBOutlet UIImageView *myImage;
@property (nonatomic, strong) UIImage *image;
secondViewController.m
@implementation ECDEditViewController
@synthesize myImage;
@synthesize image;
- (id)initWithImage:(UIImage *)aImage {
self = [super init];
if (self) {
if (!aImage) {
NSLog(@"sorry no picture loaded®");
return nil;
}
self.image = aImage;
[myImage setImage:aImage];
NSLog(@"picture loaded");
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"im trying");
[myImage setImage:image];
[myImage setContentMode:UIViewContentModeScaleAspectFit];
}