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 01-09-2010, 06:56 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 12
lenix is on a distinguished road
Default Getting the size of a view added using IB?

Hello guys,

Let's say you add a UIView subclass to your project, you add a view using IB and associate it to that subclass ( using inspector ).. How can I retrieve the width\height of the view using code?


I'm doing this because I want to do some dynamic layout according to the size of the view.

I know it's achievable if I create the UIView using code ( instead of IB ) but I'm not gonna resort to that until a while.. hoping for a solution.

Please help, I'm new to objective-c.

Many thanks in advance
lenix is offline   Reply With Quote
Old 01-09-2010, 08:27 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 342
flamingliquid is on a distinguished road
Default

IBOutlet MyView *view;

CGRect rect = view.bounds; // (or view.frame depending on what you are trying to do)

float width = rect.size.width;
float hieight = rect.size.height;
flamingliquid is offline   Reply With Quote
Old 01-10-2010, 05:59 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 12
lenix is on a distinguished road
Default

Quote:
Originally Posted by flamingliquid View Post
IBOutlet MyView *view;

CGRect rect = view.bounds; // (or view.frame depending on what you are trying to do)

float width = rect.size.width;
float hieight = rect.size.height;
Thanks, worked. <3
lenix is offline   Reply With Quote
Reply

Bookmarks

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: 335
15 members and 320 guests
akacaj, alexP, ClerurcifeDer, Domele, Duncan C, givensur, GraffitiCircus, JmayLive, michelle, NetGuru, NSString, Paul Slocum, Sloshmonster, soohyun, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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