我使用了一个带有页眉和页脚的UITableView,整个TableView里面都有水平的UIScrollViews。我将其用作锁定标题函数,就像在Excel中一样。
UserInteraction在UIScrollView的UITableview页眉和UITableView页脚中被禁用,并且仅在正文滚动时滚动。
在我的标题中,我现在有一个按钮,它位于UIScrollViews ContentView中,我需要能够与它交互,它不...有没有人在过去遇到过这种情况?
许多不需要的代码都被省略了……
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UITableViewHeaderFooterView *viewHeader;
UIButton *flow;
viewHeader = [[UITableViewHeaderFooterView alloc] initWithFrame:CGRectMake(0, 1, self.tableview.frame.size.width, 48)];
UIView *thisContentView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, contentWidth, 48)];
flow = [[UIButton alloc] initWithFrame:CGRectMake( flowRate.frame.origin.x + flowRate.frame.size.width + 5, 14, colWidth1, 20)];
[flow.imageView setImage:[UIImage imageNamed:@"ic_flow"]];
flow.imageView.contentMode = UIViewContentModeScaleAspectFit;
[flow setContentMode:UIViewContentModeScaleAspectFit];
[UniversalMethods tintImageviewInButton:flow withColor:BRIGHT_BLUE];
[flow addTarget:self action:@selector(showSortingAlert:) forControlEvents:UIControlEventTouchUpInside];
[thisContentView addSubview:flow];
[thisScrollview addSubview:thisContentView];
thisScrollview.contentSize = thisContentView.frame.size;
thisScrollview.tag = scrollTag;
[thisScrollview setUserInteractionEnabled:false];
[viewHeader addSubview:thisScrollview];
return viewHeader;
}发布于 2017-07-25 23:20:06
当在视图上禁用userInteraction时,它还会阻止触摸事件向下传递到其子视图。您需要在滚动视图上启用userInteraction,才能点击该按钮。您可以将isScrollEnabled设置为false,以防止滚动视图滚动。
https://stackoverflow.com/questions/45307054
复制相似问题