ajay
ajay

Reputation: 3345

Viewcontroller's view fram doesn't give accuratly

I am using two approaches for to place my viewcontroller

Approach 1: Taking UIViewController and pushing the viewcontroller as like below [self.navigationController pushViewController:myViewController animated:YES];

Approach 2:Taking UIViewcontroller then I am using

[self presentModalViewController:myViewController animated:YES];

While I am using the Approach1 "myViewController" view size giving as expected like portrait is 768*1024 coming to landscape is 1024*768.But the Approach2 is not providing the expected sizes as like first Approach, for both the orientations it is giving me 768*1024

Problem: What is the issue in the second Approach? Is there any solution to over come the issue.

In the project I have to use second Approach only. But I need to get the correct dimensions.Provide me some suggestions.

My Viewcotrollers hierarchy:

1)My project based on UITabBarViewController and It is restricted to portrait only.

2)One of the UITabBarButton loads another ViewController ( BookBagViewController *bookBagViewController = [[BookBagViewController alloc] init]; theNavigationController = [[UINavigationController alloc] initWithRootViewController:bookBagViewController];)

3)BookBagViewController is also restricted for portrait.

4)BookBagViewController contains one button once I click on it below code will be executed

MyViecontroller *viewer = [[MyViecontroller alloc] initWithNibName:@"MyViecontroller" bundle:nil];
[self presentModalViewController:viewer animated:YES];

5)MyViecontroller is supporting all the orientations as expected but not giving accurate frame size while printing (debugging).

6)For returning I am using below line

[self dismissModalViewControllerAnimated:YES];

For more info I provided above steps. Please accept it, even it is lengthy.

Upvotes: 0

Views: 71

Answers (1)

Rui Peres
Rui Peres

Reputation: 25917

First Approach:

You are pushing the UIViewController inside of a UINavigationController. Besides the size of your UIView (which is the root of your UIViewController) you also need to remember the size of the UINavigationBar of the UINavigationController.

Second Approach:

You are presenting the full size of your UIViewController on the screen (you are not putting it inside of anything).

As for your problem, it's a bit weird the sizes are not actually updating according to the orientation. Could you show where you are printing those values?

Upvotes: 0

Related Questions