简体   繁体   English

iOS定向问题从横向到纵向

[英]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种方法:

  1. First and i think the best: https://stackoverflow.com/a/10533561/2204866 首先,我认为最好的是: https : //stackoverflow.com/a/10533561/2204866
  2. Or you can create separates views with separate xib's for each mode. 或者,您可以为每种模式使用单独的xib创建单独的视图。 Easiest way to support multiple orientations? 支持多种方向的最简单方法? How do I load a custom NIB when the application is in Landscape? 当应用程序处于横向模式时,如何加载自定义NIB?
  3. And the last use auto layout. 最后使用自动布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS:纵向/横向网格 - iOS: grid in portrait / landscape orientation 从横向启动应用程序时,锁定IOS中的肖像方向 - Lock Portrait Orientation in IOS on Application Boot from Landscape ios iframe只有在方向从纵向更改为横向后才能展开 - ios iframe unscrollable only after orientation change from portrait -> landscape 通过单击 iOS 中的按钮将设备方向从纵向更改为横向 - Change the device orientation from portrait to landscape on a button click in iOS iOS为纵向时返回横向 - iOS return landscape orientation when is Portrait IOS设备方向卡在纵向模式下,没有横向 - IOS Device Orientation Stuck at Portrait mode, no Landscape 如何在IOS的xamarin.forms中将单个ContentPage的方向从纵向更改为全部(横向/纵向)。 - How to change orientation from Portrait to All (Landscape/Portrait both) for the single ContentPage in xamarin.forms for IOS? 从横向更改为纵向时 Xamarin iOS 应用程序崩溃 - Xamarin iOS app crashes when changing from Landscape orientation to Portrait orientation 横向定向屏幕中的ios横向屏幕结果 - ios landscape-orientation screen in portrait orientation results 方向改变从横向到纵向的工作都很奇怪 - orientation change working strangely from landscape to portrait
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM