Question

I have everything i want working up to the view you can see in the picture, i don't want the image to load on the same screen, how can i get it to load in a new screen. i have tried a few tutorials, i have had no luck as yet

The image that has been loaded from the gallery is the brick wall in the background.

the reason i want to load it in a new screen is so i can put a new toolbar that will allow me to drag images and overlay them on top of the image selected from taller or taken with the camera

Thanks in advance and sorry for asking about something that sounds so simple, I'm just very new to all this.

http://imageshack.com/a/img845/4808/9lz8.png

- (IBAction)selectPhoto:(UIButton *)sender {

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

[self presentViewController:picker animated:YES completion:NULL];


}

#pragma mark - Image Picker Controller delegate methods

- (void)imagePickerController:(UIImagePickerController *)picker    
didFinishPickingMediaWithInfo:(NSDictionary *)info {

UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;

[picker dismissViewControllerAnimated:YES completion:NULL];

}

How do i open new screen when didFinishPickingMediaWithInfo

If you need to see me more code please let me know which, I'm not sure what code you need to see :) thank you for your reply.

Était-ce utile?

La solution

If you want the image to load on a new screen, you'll need to create a second viewController, and add an imageView to that viewController.

then in your didFinishPicking method, instead of setting the image to the imageView of the current ViewController, instantiate a new imageController, set the imageView property of the new viewController, and then push your new viewController onto the navigation stack if you're using a navigation controller. If you're not using a navigation controller, you could just push the second view controller modally.

So in your didFinishPicking method it would be

UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
NewViewController *newViewController = [[NewViewController alloc] init];
newViewController.imageView.image = chosenImage; //or whatever the imageView property is called of your new view controller
[self presentViewController:newViewController animated:YES completion:nil];

(I haven't tested this code - it's off the top of my head so reader caution advised and this is the modal method)

Autres conseils

Let's try:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:^{
  // I think you should not call `presentViewController` newViewController at this screen because it maybe be destroyed
  // So, call newViewController at parentClass by delegate of block
  // and assign new image to the screen which need to show
}];

}

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top