Reputation: 375
I am creating a simple UIButton programmatically with this frame size
UIButton *pickmeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - 100, self.view.bounds.size.width, 60)];
it display at perfect place where i want
But on some action i want to reload the whole view controller, when i do it display the button at wrong coordinates
First, i am unable to find the reason for it. Second, what i think according to coordinates i have defined i think the second image is rendering the correct coordinates because, placement on Y coord is (self.view.bounds.size.height - 100) and height is 60. But when i make it -60 it starts displaying button below bottom line and very little of button shows up above.
Kindly share your views and solution on this.
Upvotes: 0
Views: 93
Reputation: 286
Please try with this.
UIButton *pickmeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - 60, [UIScreen mainScreen].bounds.size.width, 60)];
Upvotes: 0
Reputation: 1742
Set AutoresizingMask for button
UIButton *pickmeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - 60, self.view.bounds.size.width, 60)];
[pickmeButton setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin];
Upvotes: 3