Ios 如何从当前方向查看控制器初始化(尤其是在横向中)?
我有一个视图控制器,名为AViewController。AViewController中有一个按钮。单击按钮时,我将显示另一个视图控制器,名为BViewController。如果AViewController是纵向的,则工作正常。如果方向是横向的,则BViewController仍以纵向初始化,但以横向显示 这就是问题所在。我想知道如何在当前方向初始化BViewController。我使用BViewController的init中的[UIScreen mainScreen]。边界。但如果设备处于横向,则边界不在横向。我知道将框架从AViewController传递到BViewController,它可能会工作。但我认为这不是一个好的解决方案。有没有更好的办法 显示BViewController的功能如下:Ios 如何从当前方向查看控制器初始化(尤其是在横向中)?,ios,ipad,uiviewcontroller,Ios,Ipad,Uiviewcontroller,我有一个视图控制器,名为AViewController。AViewController中有一个按钮。单击按钮时,我将显示另一个视图控制器,名为BViewController。如果AViewController是纵向的,则工作正常。如果方向是横向的,则BViewController仍以纵向初始化,但以横向显示 这就是问题所在。我想知道如何在当前方向初始化BViewController。我使用BViewController的init中的[UIScreen mainScreen]。边界。但如果设备处于
- (void)BtnClicked
{
BViewController *bvc = [[BViewController alloc] init];
bvc.delegate = self;
bvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:movie animated:YES completion:nil];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0];
}
我仍然不知道如何有效地做。但是我使用了一种解决方案,在
viewdide
中手动调用willanimaterotationInterfaceOrientation
方法
片段如下所示:
- (void)BtnClicked
{
BViewController *bvc = [[BViewController alloc] init];
bvc.delegate = self;
bvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:movie animated:YES completion:nil];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0];
}