I'm working on an iPad project, currently it's on Landscape view. And I tried doing:
self.view.frame.size.height
Why is this always returning 960? While as in landscape the height dimension of the view itself should be 768 right?
What I am trying to do is to allocInitWithFrame a UIToolbar that is located at the bottom. The UIToolBar has a height of 50, so here's what I did which failed:
self.bottom_bar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.frame.size.height-50, self.view.frame.size.width, 50)];
Why is this and how do I do this?
1) Control-drag from a frame view (e.g. questionFrame) to main View, in the pop-up select "Equal heights". 2)Then go to size inspector of the frame, click edit "Equal height to Superview" constraint, set the multiplier to 0.7 and hit return.
Frame A view's frame ( CGRect ) is the position of its rectangle in the superview 's coordinate system. By default it starts at the top left. Bounds A view's bounds ( CGRect ) expresses a view rectangle in its own coordinate system.
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.
layoutSubviews() The system calls this method whenever it needs to recalculate the frames of views, so you should override it when you want to set frames and specify positioning and sizing. However, you should never call this explicitly when your view hierarchy requires a layout refresh.
Two postings (one and two) referenced a similar problem. They both suggest using self.view.bounds instead of self.view.frame.size.width because the bounds change along with the interface orientation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With