以模态方式呈现的TableViewController不会滚动到底部

时间:2016-03-22 07:05:51

标签: ios xcode tableview presentviewcontroller

我目前正在使用 CollectionViewController ,点击单元格会显示详细视图控制器( TableViewController )。

以模式方式显示TableVC的代码:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *detailVC = [storyboard instantiateViewControllerWithIdentifier:@"DetailTimetableViewController"];

[self presentViewController:detailVC animated:true completion:nil];

使用上面的代码工作正常,表视图控制器以模态方式显示,滚动表现正常。

但是,我遵循了本教程(http://blog.matthewcheok.com/design-teardown-preview-expanding-cells/),它创建了一个自定义 UIViewControllerAnimatedTransitioning ,我已经从教程中获得了所有工作完全没问题。

以模式方式显示TableVC的代码(使用自定义动画):

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *detailVC = [storyboard instantiateViewControllerWithIdentifier:@"DetailTimetableViewController"];

ExpandingCellTransition *transition = [[ExpandingCellTransition alloc]init];
detailVC.transitioningDelegate = transition;

[self presentViewController:detailVC animated:true completion:nil];

但是,除了提供TableViewController时,一切都工作正常,它不允许滚动到底部,并且在某个高度受到限制。

我已尝试搜索类似的问题(TableViewController无法滚动到底部),并尝试应用他们的解决方案,但没有一个工作,我相信问题的原因来自自定义转换委托。

4 个答案:

答案 0 :(得分:0)

试试这个

// Obj-C
self.automaticallyAdjustsScrollViewInsets = NO;

// Swift
self.automaticallyAdjustsScrollViewInsets = false

希望可以帮到你

答案 1 :(得分:0)

MainViewController viewDidLoad方法中,添加以下代码:self.automaticallyAdjustsScrollViewInsets= NO

答案 2 :(得分:0)

set tableviewProperty tableview.UITableViewAutomaticDimension = YES

答案 3 :(得分:0)

use following code in cellForrowAtindexPath delegate method:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];

    // Configure the cell...

    return cell;
}