1

我有一个拆分视图控制器,其中包含一个选项卡控制器,该控制器在其每个选项卡项中都包含一个表视图 - 全部位于“主端”。表格视图提供了用户可以从中选择的项目列表,以控制“详细信息侧”上显示的内容。

我试图在用户做出选择后将主表视图移出屏幕 - 而不是用户需要点击屏幕来关闭主表视图。

我正在使用下面的代码。正如代码注释所示,它会留下一个半透明的“阴影”来代替主侧表视图。我还需要做什么才能将主边桌视图完全移出屏幕。

- (void)hideSidebarNavPanel
{
    /*  This almost works - in that it moves the table view off the screen but leaves a "shadow" in its place. 
        This occurs whether we modify the frame for the tabBarView or the masterTableView or the masterView - or for all 3.
        It seems that there is something else sitting below both of these that also needs to have its frame modified.
        The question is what?
     */

    UIView *masterView = self.view;
    CGRect masterViewFrame = masterView.frame;
    masterViewFrame.origin.x -= masterViewFrame.size.width;

    NSArray *controllers = self.splitViewController.viewControllers;
    UITabBarController *tabBarController = [controllers objectAtIndex:0];

    UIView *tabBarView = tabBarController.view;
    CGRect tabBarFrame = tabBarView.frame;
    tabBarFrame.origin.x -= tabBarFrame.size.width;

//    UIViewController *masterNavigationController = [tabBarController.viewControllers objectAtIndex:0];
//    UIView *masterTableView = masterNavigationController.view;
//    CGRect masterTableViewFrame = masterTableView.frame;
//    masterTableViewFrame.origin.x -= masterTableViewFrame.size.width;       

    [UIView beginAnimations:@"showView" context:NULL];
    masterView.frame = masterViewFrame;
    tabBarView.frame = tabBarFrame;
    //masterTableView.frame = masterTableViewFrame;
    [UIView commitAnimations];
}
4

0 回答 0