Reputation: 5122
I am using a UIScrollView in an iPhone xib, and a property called myScrollView to read the size of the scroll view.
@property (weak, nonatomic) IBOutlet UIScrollView *myScrollView;
When I try to read or use the bounds.size of the scroll view it comes out different than the dimentions I have set up in the xib scaled to 320 x 117. But myScrollView.bounds.size.height returns 583. Shouldn't it read the same? Should I set the size some other way?
log statement:
NSLog(@"scrollview x y: %f,%f", myScrollView.bounds.size.width, myScrollView.bounds.size.height);
output:
2012-06-28 11:38:13.150 MyApp[1380:707] scrollview x y: 320.000000,583.000000
Upvotes: 0
Views: 3097
Reputation: 936
The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).
The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.
You are setting the frame not the bounds in interface builder.
Upvotes: 1