I am currently learning how to work in Objective-C / Cocoa Touch and I am stuck with what I’m sure is a very simple problem….
I have a ViewController with an array imageList from where I pass the selected image name to the nextController
[nextController newimg:[imagesList objectAtIndex:indexPath.row]];
In nextController I have an UIImageView that sets up an overlay image and I can’t figure out how to set it that it’s availeable there.
UIImageView *myImage;
-(void)viewDidLoad{.....
myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", (NSString *)currentImage]];
[myImage setImage:image];
I need to figure out how to set “currentImage” to the value passed from the other ViewController.
I can set the image Name and it will show with NSLog but it will not be available in viewDidLoad.
- (void)newimg:(NSString *)_text;
{
NSString *img = (NSString *)_text;
}
I would greatly appreciate if someone can point me in the right direction.
TIA!
You don’t have to initialize UIImageView in viewDidLoad, you can do this in the setter function where you set the imagename.
Another option is to set the image name before showing the view, this way you will have the imagename set before viewDidLoad is called.