[英]iOS Orientation issue from landscape to portrait
I've lost enough sleep trying to figure this one out. 我已经睡不着了,试图找出答案。 I have a tabbed application that supports all orientations.
我有一个支持所有方向的选项卡式应用程序。 Everything works completely fine when the app starts in portrait and switches to landscape.
当应用程序以纵向启动并切换为横向时,一切工作都完全正常。 When the app starts in landscape however and then switches to portrait, I lose response ONLY on the bottom quarter of the screen!
但是,当应用在横向模式下启动,然后切换为纵向模式时,我只会在屏幕的下半部分失去响应! It's as if something in the background is not adjusting the "user interaction" area from landscape bounds to portrait bounds when the orientation changes.
当方向改变时,似乎背景中的某些内容无法将“用户交互”区域从横向范围调整为纵向范围。
I have two tabs at the moment. 我目前有两个标签。 When I switch to the second tab, and then back to the first, the problem goes away!
当我切换到第二个选项卡,然后再回到第一个选项卡时,问题就消失了! I'm able to interact with the bottom quarter of the screen again.
我可以再次与屏幕的下半部分进行互动。 I've gotten that similar problem before when I setup the tab view controller away in viewDidLoad as opposed to viewDidAppear.
当我在viewDidLoad(而不是viewDidAppear)中设置选项卡视图控制器之前,遇到了类似的问题。 Everything is in viewDidAppear now.
现在一切都在viewDidAppear中。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidAppear:(BOOL)animated
{
NSArray* controllers = nil;
TimeTableViewController * timeTableViewController = [[TimeTableViewController alloc] init];
FRLayeredNavigationController *timeTableNavController = [[FRLayeredNavigationController alloc] initWithRootViewController:timeTableViewController configuration:^(FRLayeredNavigationItem *item)
{
item.hasChrome = YES;
}];
timeTableNavController.dropLayersWhenPulledRight = true;
TestViewController* vc2 = [[TestViewController alloc] init];
timeTableNavController.tabBarItem = [[UITabBarItem alloc]
initWithTitle:@"Student Lookup"
image:[UIImage imageNamed:@"search_gray.png"]
tag:0];
timeTableNavController.tabBarItem = [[UITabBarItem alloc]
initWithTitle:NSLocalizedString(@"Attendance", @"Attendance")
image:[UIImage imageNamed:@"attendance_gray.png"]
tag:0];
timeTableNavController.view.backgroundColor = [UIColor lightGrayColor];
controllers = [NSArray arrayWithObjects:timeTableNavController,vc2, nil];
self.viewControllers = controllers;
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
I don't think the FRLayeredNavigationController library is an issue. 我认为FRLayeredNavigationController库不是问题。 Is there any method I can call that readjusts the "area of response" when switching from landscape to portrait?
从风景切换为人像时,我可以调用任何方法来重新调整“响应区域”吗? That would be a life-saver.
那将是救生员。 Someone please beat some sense into me!
有人请打理一下我!
In fact when you start your app in landscape mode, it should starts in portrait and then your viewcontroller need to rotate this. 实际上,当您以横向模式启动应用程序时,它应该以纵向启动,然后您的视图控制器需要旋转它。
In fact you have 3 approaches: 实际上,您有3种方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.