Reputation: 438
Some very strange issue for me:
- (void)horizontalPickerView:(HorizontalPickerView *)picker didSelectElementAtIndex:(NSInteger)index {
if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
sdashSize = CGRectMake(0.0f, 40.0f, self.view.frame.size.width, self.view.frame.size.height);
} else {
sdashSize = CGRectMake(0.0f, 40.0f, self.view.frame.size.height, self.view.frame.size.width - 40.0f);
}
}
Like you see, I have a picker view. This method runs every time, that I select something in this picker view. So now if I rotate my iPhone into Landscape and go to the next view with this code, it runs once -> goes to if state and gives me size: 320 x 480. So now select some element at the same orientation and runs the same code (if state once again) gives me 480 x 320. I do not understand how could the same code at the same orientation could give me the different values.
Upvotes: 0
Views: 747
Reputation: 5240
Don't use the frame
property, use the bounds
property. In essence:
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.
A view's bounds (CGRect) expresses a view rectangle in its own coordinate system.
This answer explains further in depth what is going on.
Upvotes: 2