Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing URL into method
    text
    copied!<p>Hi i have a question here,</p> <p>i'm able to get the UrL string store in "imageName" variable successfully in showImage method.</p> <p>I need to do the same in this method "segmentedControlIndexChanged" but i cant get the variable "imageName".</p> <p>Is there anyway i can declare the IBAction method to work similarly as the showImage method? </p> <p>I Tried ->" <code>-(IBAction) segmentedControlIndexChanged:(NSString *)imageName{}</code> " but it cant work, i'm unable to get the variable "imageName". </p> <pre><code>- (void) showImage:(NSString *)imageName { NSData *imageData; //NSString * string1 = [NSString stringWithFormat:imageName]; imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imageName]]; //NSLog(@"%@",imageName); image = [[UIImage alloc] initWithData:imageData]; self.imageView.image = image; [imageView setFrame:CGRectMake(5, 10, image.size.width, image.size.height)]; [scrollview setScrollEnabled:YES]; if(image.size.height+20 &gt;= 224) { [scrollview setContentSize:CGSizeMake(289, image.size.height + 20)]; } else { [scrollview setContentSize:CGSizeMake(289, 224)]; } } //////// -(IBAction) segmentedControlIndexChanged{ switch (self.segmentedControl.selectedSegmentIndex) { case 0: image = [UIImage imageNamed:image1name]; self.imageView.image = image; [imageView setFrame:CGRectMake(5, 10, image.size.width, image.size.height)]; [scrollview setScrollEnabled:YES]; if(image.size.height+20 &gt;= 224) { [scrollview setContentSize:CGSizeMake(289, image.size.height + 20)]; } else { [scrollview setContentSize:CGSizeMake(289, 224)]; } break; case 1: image = [UIImage imageNamed:image2name]; self.imageView.image = image; [imageView setFrame:CGRectMake(5, 10, image.size.width, image.size.height)]; [scrollview setScrollEnabled:YES]; [scrollview setContentSize:CGSizeMake(289, image.size.height+20)]; break; case 2: image = [UIImage imageNamed:image3name]; self.imageView.image = image; [imageView setFrame:CGRectMake(5, 10, image.size.width, image.size.height+1)]; [scrollview setScrollEnabled:YES]; [scrollview setContentSize:CGSizeMake(289, image.size.height+20)]; break; default: break; } } </code></pre> <p><strong>EDIT</strong></p> <p>I have encountered Bad Access error, anyone knows what does it mean or can anyone show me some ways to solve it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload