Tutorial :Set UIImage of a new view and display it


I'm trying to set the image of a new view. I set the controller's image an then display the view. But in the controller's viewDidLoad, no image is available.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {    EditPictureSaveViewController *editPictureController = [EditPictureSaveViewController alloc];    [editPictureController initWithNibName:@"EditPictureSaveView" bundle:[NSBundle mainBundle]];    UIImageView *imageView = [ [ UIImageView alloc ] initWithImage: image ];  [imageView setImage:image];  [editPictureController setPreview:imageView];    [self.navigationController pushViewController:editPictureController animated:YES];  


That's because viewDidLoad is called by

[editPictureController initWithNibName:@"EditPictureSaveView" bundle:[NSBundle mainBundle]];  

after the NIB is loaded.

editPictureController's image property (which I assume is a UIImageView - confusing!) is not set until after this.

Do whatever you're doing in viewDidLoad in the viewWillAppear: method instead - your image property will be set when pushViewController:animated: calls viewWillAppear:.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »