suchen

Heim  >  Fragen und Antworten  >  Hauptteil

objective-c - addSubView 添加一个tableView,不能正常滚动

代码:

- (void)viewDidLoad
{
  [super viewDidLoad];
    // Do any additional setup after loading the view.
  groupViewController = [GroupViewController groupTableViewControllerWithDataSource:[GroupDataSource instance]
                                                                              Delegate:self];

  [self addChildViewController:groupViewController];
  [_groupView addSubview:groupViewController.view];
}

症状:
成功添加并显示,但tableView 无法滚动到底。怀疑是布局的问题,求教。

迷茫迷茫2768 Tage vor328

Antworte allen(1)Ich werde antworten

  • 天蓬老师

    天蓬老师2017-04-22 09:01:40

    这里要重新设置frame的

    - (void)addChild:(UIViewController *)childToAdd withChildToRemove:(UIViewController *)childToRemove
    {
        assert(childToAdd != nil);
    
        if (childToRemove != nil)
        {
            [childToRemove.view removeFromSuperview];
        }
        CGRect frame = childToAdd.view.frame;
        frame.size.height = CGRectGetHeight(self.placeHoderView.frame);
        frame.size.width = CGRectGetWidth(self.placeHoderView.frame);
        childToAdd.view.frame = frame;
        self.currentVC = childToAdd;
        [self.placeHoderView addSubview:childToAdd.view];
    }
    

    Antwort
    0
  • StornierenAntwort