只显示其中一个子视图

时间:2013-11-16 05:28:07

标签: ios uiimageview uistoryboardsegue

我正在使用segue将2个图像视图传递到下一个视图,并且只显示其中一个图像。我无法在任何地方找到解决方案。

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];

    }
}

更新:至于其中一条评论,这是它的样子: 假设左边是另一只眼睛。

enter image description here

编辑:

 @interface WeatherEyeViewController_4inch_White : UIViewController {

    IBOutlet UIImageView *CloudyBlue;
    IBOutlet UIImageView *CloudyBlue1;

}

我明白了!而不是像上面那样创建它。我像这样创建它们并且它有效!

    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"]];

2 个答案:

答案 0 :(得分:0)

请勿使用CGRectMake对核心进行核心处理。相反,您应该在故事板中设置帧,或者更确切地说,通过指定自动布局约束来设置帧。通过使用自动布局,您可以更改视图,这是旋转界面时的合适方式。

答案 1 :(得分:0)

我明白了!而不是像上面那样创建它。我像这样创建它们并且它有效!

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"]];