【问题标题】:How to avoid resizing of UITableView inside UiNavigationcontroller which is inside a custom container(stackedViewcontroller)如何避免在自定义容器(stackedViewcontroller)内的 UiNavigationcontroller 内调整 UITableView 的大小
【发布时间】:2012-11-10 00:37:19
【问题描述】:
MoveToNewLocViewContoller *move2NewLocVC = [[MoveToNewLocViewContoller alloc] initWithLocItemArray:moveToNewLocArray andSyLocIDArray:syLocIdArray];
        [move2NewLocVC setTitle:cell.textLabel.text];


        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:move2NewLocVC];
        navController.view.width = PSIsIpad() ? self.view.width : 100;
        [navController.navigationBar setTintColor:BLUE];


        if (navController) {

            [XAppDelegate.menuInterfaceViewController.stackViewController pushViewController:navController fromViewController:nil animated:YES];
            [navController release];
            //[viewController release];
            [moveToNewLocArray release];
            [move2NewLocVC release];
        }

现在我希望上面的导航控制器在我旋转 ipad 时不会调整大小。我试过了 navController.view.autoresizesSubviews = NO;

这可行,但有一个问题是它不允许我的 UITableView(MoveToNewLocViewController) 滚动到底部。避免调整大小的主要目的是避免重绘我巨大的自定义 UITableViewcell 以适应方向。我知道我必须在定向后调整 UiTableview 的大小,但问题是在哪里。我试过了

 -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {}

-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {}

它似乎不起作用。这是因为我将它插入到堆叠容器视图中吗?

任何帮助将不胜感激。

【问题讨论】:

    标签: ipad uitableview ios5 uinavigationcontroller screen-orientation


    【解决方案1】:

    我通过在 UIView 中包含 UITableView 来解决这个问题,然后将其作为 UIViewController 添加到 UiNavigationController。当设备旋转时,我在 didRotateFrominterfaceOrientation 方法中调整视图大小

    -(void) didRotateFromInterfaceOrientation:  (UIInterfaceOrientation)fromInterfaceOrientation
      PSStackedViewController *stackController = XAppDelegate.menuInterfaceViewController.stackViewController;
    if( [[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortraitUpsideDown){
        [stackController setLargeLeftInset:50 animated:YES];
        self.navigationController.navigationBar.frame = CGRectMake(self.navigationController.navigationBar.frame.origin.x, self.navigationController.navigationBar.frame.origin.y, self.view.frame.size.width, self.navigationController.navigationBar.frame.size.height);
        self.move2NewLocTableView.height = self.view.height;
    }
    if( [[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeRight) {
        //self.navigationController.view.frame = self.tableView.frame;
        [stackController setLargeLeftInset:320 animated:YES];
        self.move2NewLocTableView.height = 700;
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-05
      • 1970-01-01
      • 1970-01-01
      • 2012-12-04
      相关资源
      最近更新 更多