Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-21-2010, 11:13 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 84
Shubo is on a distinguished road
Default How to autoresize subview

This seems simple and works on views created in Interface Builder but I can't get it work on views created programmatically. I'm trying to resize subviews proportionally when the superview is resized but it's not working. Here's the simplified version of the code:

- (void)viewDidLoad {
[super viewDidLoad];

UIView *v = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 100, 100)];
v.backgroundColor = [UIColor redColor];
[self.view addSubview:v];
v.autoresizesSubviews = YES;
v.autoresizingMask = UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleWidth;

UIView *v2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
v2.backgroundColor = [UIColor blueColor];
[v addSubview:v2];

v.frame = CGRectMake(20, 20, 50, 50);

[v release];
[v2 release];
}

Please help. Thanks.
Shubo is offline   Reply With Quote
Old 10-21-2010, 09:33 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 84
Shubo is on a distinguished road
Default

Does anybody have any idea? Your help would be greatly appreciated.
Shubo is offline   Reply With Quote
Reply

Bookmarks

Tags
resize, subview, superview, view

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 339
9 members and 330 guests
condor304, Desert Diva, dre, hain, mottdog, oceanlablight, palme2elie, schmallegory
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,658
Threads: 94,118
Posts: 402,895
Top Poster: BrianSlick (7,990)
Welcome to our newest member, palme2elie
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:11 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0