Search code examples
iosuiimageviewuistoryboardsegue

Only one of these subviews is being shown


I am passing 2 imageviews to the next view using a segue and only one of the images is being shown. I can't find a fix for this anywhere.

Code for the segue:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([segue.identifier isEqual:@"CloudyBlue"]) {

        Level1_4inch_White *dest = [segue destinationViewController];
        CloudyBlue.frame = CGRectMake(78, 277, 139, 100);
        CloudyBlue1.frame = CGRectMake(363, 277, 139, 100);
        [dest.view addSubview:CloudyBlue];
        [dest.view addSubview:CloudyBlue1];

    }
}

UPDATE: As to one of the comments, here is what It looks like: There is suppose to be another eye on the left.

enter image description here

EDIT:

 @interface WeatherEyeViewController_4inch_White : UIViewController {

    IBOutlet UIImageView *CloudyBlue;
    IBOutlet UIImageView *CloudyBlue1;

}

I figured it out! Instead of creating it like above. I create them like this and it works!

    UIImageView *CloudyBlue = [[UIImageView alloc] initWithFrame:CGRectMake(78, 277, 139, 100)];
    UIImageView *CloudyBlue1 = [[UIImageView alloc] initWithFrame:CGRectMake(363, 277, 139, 100)];
    [CloudyBlue setImage:[UIImage imageNamed:@"Cloudy-Eye-Blue.png"]];
    [CloudyBlue1 setImage:[UIImage imageNamed:@"Cloudy-Eye-Blue.png"]];

Solution

  • I figured it out! Instead of creating it like above. I create them like this and it works!

    UIImageView *CloudyBlue = [[UIImageView alloc] initWithFrame:CGRectMake(78, 277, 139, 100)];
    UIImageView *CloudyBlue1 = [[UIImageView alloc] initWithFrame:CGRectMake(363, 277, 139, 100)];
    [CloudyBlue setImage:[UIImage imageNamed:@"Cloudy-Eye-Blue.png"]];
    [CloudyBlue1 setImage:[UIImage imageNamed:@"Cloudy-Eye-Blue.png"]];