I'm trying to resize subviews (UIImageView) inside a subview, but I'can deal with it.
I've a UIView which contain five UIImageViews as subviews, side by side: the UIView has a width of 400 px, and each subview has a width of 80 px (their xOrigins are 0, 80, 160,...).
How can I resize the UIVIew to 800 px width and resize automatically its subviews to 160 px width and xOrigins at 0, 160, 320,...?
Different conbinations of UIViewAutoresizingFlexibleHeight, UIViewAutoresizingFlexibleWidth, UIViewAutoresizingFlexibleLeftMargin, UIViewAutoresizingFlexibleRightMargin, UIViewAutoresizingFlexibleTopMargin, UIViewAutoresizingFlexibleBottomMargin haven't solved my problem.
Any help?
CODE: UIView *mainView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 400, 200)]; mainView.autoresizesSubviews = YES; [self.view addSubview:mainView];
UIImageView *view1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 200)];
view1.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
view1.backgroundColor = [UIColor color1];
[mainView addSubview:view1];
UIImageView *view2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 80, 80, 200)];
view2.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
view2.backgroundColor = [UIColor color2];
[mainView addSubview:view2];
UIImageView *view3 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 160, 80, 200)];
view3.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
view3.backgroundColor = [UIColor color3];
[mainView addSubview:view3];
UIImageView *view4 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 240, 80, 200)];
view4.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
view4.backgroundColor = [UIColor color4];
[mainView addSubview:view4];
UIImageView *view5 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 320, 80, 200)];
view5.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
view5.backgroundColor = [UIColor color5];
[mainView addSubview:view5];