1
votes

I have one view controller, named AViewController. There is a button in AViewController. When the button is clicked, i will present another view controller,lets called BViewController. If AViewController is in portrait-orientation, it works well.If the orientation is in landscape, then the BViewController is still initialized in portrait but presented in landscape.

This is the problem. I wonder how can i init BViewController in current orientation. I use [UIScreen mainScreen].bounds in the BViewController's init. but the bounds is not in landscape if the device is in landscape. I know pass the frame from AViewController to BViewController, it may work. but i don't think this is a good solution. So is there any better ways?

the function to present BViewController is as follows:

- (void)BtnClicked
{
    BViewController *bvc = [[BViewController alloc] init];
    bvc.delegate = self;
    bvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:movie animated:YES completion:nil];
}
1

1 Answers

0
votes

I still don't know how to do it efficiently. But i use one solution to call the willAnimateRotationToInterfaceOrientation method manually in viewDidAppear.

the snippet is as follows:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0];
}