【问题标题】:iOS Orientation issue from landscape to portrait从横向到纵向的iOS方向问题
【发布时间】:2013-12-02 07:54:12
【问题描述】:

我已经失去了足够的睡眠试图弄清楚这一点。我有一个支持所有方向的选项卡式应用程序。当应用程序以纵向启动并切换到横向时,一切正常。但是,当应用程序以横向启动然后切换到纵向时,我仅在屏幕的底部四分之一处失去响应!当方向改变时,就好像背景中的某些东西没有将“用户交互”区域从横向边界调整为纵向边界。

我现在有两个标签。当我切换到第二个选项卡,然后回到第一个选项卡时,问题就消失了!我能够再次与屏幕的底部四分之一进行交互。当我在 viewDidLoad 中设置选项卡视图控制器而不是 viewDidAppear 之前,我遇到了类似的问题。现在一切都在 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.
}

我认为 FRLayeredNavigationController 库不是问题。从横向切换到纵向时,我可以调用任何方法来重新调整“响应区域”吗?那将是一个救生员。有人请给我一些理智!

【问题讨论】:

    标签: ios uitabbarcontroller uiinterfaceorientation


    【解决方案1】:

    事实上,当您以横向模式启动应用时,它应该以纵向启动,然后您的视图控制器需要旋转它。

    其实你有 3 种方法:

    1. 首先,我认为最好: https://stackoverflow.com/a/10533561/2204866
    2. 或者您可以使用单独的 xib 为每个视图创建单独的视图 模式。 Easiest way to support multiple orientations? How do I load a custom NIB when the application is in Landscape?
    3. 最后使用自动布局。

    【讨论】:

    • 哇!我实际上正在使用情节提要/外部笔尖设置。那么这可能是导致问题的原因吗?方法#3 似乎是最简单的,但是默认情况下使用自动布局,我没有禁用它,所以不要认为它会起作用。我今晚回家后会试试这个,然后告诉你。无论它是否有效,我都非常感谢您的帮助。
    • 不幸的是,自动布局不是那么灵活,就像第二个笔尖,它有很多头疼:(
    猜你喜欢
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多