简体   繁体   English

重新定位父框架时,UITableView对滚动不响应

[英]UITableView doesn't respond to scroll when parent frame is repositioned

I'm building something similar to the Twitter composition panel in their mobile app. 我正在他们的移动应用程序中构建类似于Twitter组成面板的内容。 The top half of the view has a text area while the bottom half is a table view of images. 视图的上半部分具有文本区域,而下半部分是图像的表格视图。 You can scroll the table view up and it'll push the top view offscreen and only then you can scroll up and down the table view. 您可以向上滚动表格视图,它将顶视图推离屏幕,然后才可以上下滚动表格视图。 What I have done is place my table view in a wrapper view and I change the frame of this to move both the tableview and the top view up and down (using a UIPanGestureRecognizer ). 我要做的是将表格视图放在包装器视图中,并更改其框架以上下移动表格视图和顶视图(使用UIPanGestureRecognizer )。 The problem I have is once the wrapper view has moved up from its original position, only the section of the tableview which was originally visible can be scrolled. 我遇到的问题是,包装器视图从其原始位置向上移动后,只有原本可见的表格视图部分才能滚动。 The previously offscreen part cannot scroll. 先前屏幕外的部分无法滚动。 Events are still bubbling up a couple view above. 事件仍然在上面的几个视图中冒泡。

Code below: 代码如下:

CGRect frame = self.tableView.frame;
    frame.size.height = self.superview.frame.size.height;
    [self.tableView setFrame:frame];

    self.tableView.dataSource = dataSourceDelegate;
    self.tableView.delegate = dataSourceDelegate;
    self.tableView.index = index;

    self.panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
    self.panGesture.minimumNumberOfTouches = 1.0;
    self.panGesture.delegate = self;

    self.panGesture.maximumNumberOfTouches = 1;
    self.panGesture.delaysTouchesBegan =YES;
    self.panGesture.cancelsTouchesInView = YES;


    [self.tableView reloadData];

    [self.tableView addGestureRecognizer:self.panGesture];

It was a sizing issue for the table view. 这是表格视图的大小问题。 Although it appeared to be sized correctly, it was not which meant the content size was incorrect and therefore why the scroll didn't function as expected. 尽管看起来大小正确,但这并不意味着内容大小不正确,因此,为什么滚动不能按预期运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM