I am trying change an UIImageView from other viewControllers, but I don’t know why image does not change !! here is my code :
#import "ViewController.h"
@class ViewController;
@interface CoverGallery : UIViewController {
ViewController *mainViewController;
}
@property (nonatomic,retain) ViewController *mainViewController;
- (IBAction)img1;
.m
- (IBAction)img1 {
mainViewController.coverArt.image = [UIImage imageNamed:@"coverDefault.png"];
[self dismissModalViewControllerAnimated:YES];
}
There is an UIImageView called coverArt in MainViewController , thanks
Here is my button action which switch between views :
ViewController (My First view)
.h
@interface ViewController : UIViewController {
ViewController *mainViewController;
}
@property (nonatomic, retain) ViewController *mainViewController;
.m :
@synthesize mainViewController;
- (void) CoverGallery {
CoverGallery *gallery = [[CoverGallery alloc] initWithNibName:@"CoverGallery" bundle:nil];
gallery.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:gallery animated:YES];
//here is the problem, compiler gives me the mainViewController is not the property of CoverGallery
gallery. mainViewController = self;
;
}
How are you initializing the property mainViewController? You need set it as the MainViewController by setting its property when you present the modal view.
I imagine your doing this in the MasterViewController:
I fixed a typo..
and this:
should be:
but you need to Import it in the same header file.