cari

Rumah  >  Soal Jawab  >  teks badan

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 hari yang lalu335

membalas semua(1)saya akan balas

  • 天蓬老师

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

    Anda perlu menetapkan semula bingkai di sini

    - (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];
    }
    

    balas
    0
  • Batalbalas