0

I would like to passing a uiimage from one view to another view which contains a uiwebview. So that i can allow easy interaction and gestures on the image.

But i have no idea how to code in the viewdidload method should be used.

Here is my code:

//first view
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
 if ([segue.identifier isEqualToString:@"showbig"]) {
        bigpic *image = [segue destinationViewController];
        image.bigpicture1 = set11.image;
}

//new view

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *url = [NSURL URLWithString:bigpicture1];
    NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
    [self.bigpicture loadRequest:requestURL];


}
Clarence
  • 1,951
  • 2
  • 34
  • 49
  • why you are using web view? use image view instead – Anil Varghese May 17 '13 at 12:57
  • 1
    Also, don't call a UIViewController subclass "bigpic". First it should have a capital letter, second it should be descriptive. BigPicViewController. Also, don't call an instance of this "image". At the very least it should be "controller". – Fogmeister May 17 '13 at 13:07

3 Answers3

1

In the destinationViewController you should have a property UIImage *imageThatIShouldDisplay

In your sourceView controller prepareForSegue method you will have something like this:

if ([segue.identifier isEqualToString:@"showbig"]) {
        YourDestiantionVC *vc = (YourDestiantionVC*)[segue destinationViewController];
        vc.imageThatIShouldDisplay = set1.image;
}

In your destiantion view controller viewDidLoad method you will have:

if(self.imageThatIShouldDisplay != nil) {
 imageViewThatHandlesImageDisplay.image = self.imageThatIShouldDisplay;
}
else { 
 imageViewThatHandlesImageDisplay.image = [UIImage imageWithName:@"my_image_placeholder.png"]; // in case you want a placeholder.
}
danypata
  • 9,895
  • 1
  • 31
  • 44
1

You have to load the image from your bundle to load it into the UIWebView since a UIImage can't be loaded directly into a UIWebView.

Answers

Community
  • 1
  • 1
Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42
0
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.bigpicture.image = bigpicture1;

}

as i think

p.balmasov
  • 357
  • 1
  • 16