user1007895
user1007895

Reputation: 3965

Wrong view size on 3.5 screen

When running my iOS app on a 3.5 inch iPhone Simulator, self.view.frame.size.height is reporting 548px. What is the right way to fix this?

Upvotes: 0

Views: 246

Answers (2)

John Riselvato
John Riselvato

Reputation: 12904

it's because you're calling this from viewDidLoad right?

I bet calling the NSLog in this function instead comes back with the correct height;

-(void)viewDidAppear:(BOOL)animated {
    NSLog(@"%f", self.view.frame.size.height);
}

You should really be using self.view.bounds instead of self.view.frame

for more information about why and how view this SO: "Incorrect" frame / window size after re-orientation in iPhone

Upvotes: 0

Eli Ganem
Eli Ganem

Reputation: 1479

I assume you see this behavior in viewDidLoad, right? The screen dimensions are not final while in viewDidLoad. You should only rely on the view's frame in viewWillLayoutSubviews method.

Upvotes: 2

Related Questions