My destination ViewController has a number of labels and images which need to be changed dependent on the specific previous ViewController. I have a segue set up which should change these but for some reason it is not, even though the segue is being called.
My initial ViewController has a button which has a segue passing to the next ViewController with the name "aName". I'm probably missing something simple but I have been following another section of my code which does the exact same thing and works! I have also tested that the segue is successfully being called with a NSLog which returns fine. All the IBOutlets are also assigned correctly.
Initial View Controller.m:
#import "dViewController.h"
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"aName"]) {
dViewController *dVC = (dViewController *)segue.destinationViewController;
dVC.TitleLabel.text = @"abc";
dVC.1Img.image = [UIImage imageNamed:@"somepath.jpg"];
dVC.2Img.image = [UIImage imageNamed:@"somepath2.jpg"];
[dVC.1Button setTitle:@"abcd" forState:UIControlStateNormal];
[dVC.1Button setTitle:@"efgh" forState:UIControlStateNormal];
}
Destination ViewController:
dViewController.h
@property (strong, nonatomic) IBOutlet UILabel *TitleLabel;
@property (strong, nonatomic) IBOutlet UIImageView *1Img;
@property (strong, nonatomic) IBOutlet UIImageView *2Img;
@property (strong, nonatomic) IBOutlet UIButton *1Button;
@property (strong, nonatomic) IBOutlet UIButton *2Button;
Edit: From doing some more looking around I think I should be using a delegate. It seems quite complicated and not really sure where I start. But I'll have a go at looking at what's in this thread: Changing label's text in another view controller