2017-07-25 121 views
1

我正在使用带有页眉和页脚的UITableView,整个TableView里面都有水平的UIScrollViews。我将它用作锁定标题功能,就像在Excel中一样。在没有UserInteraction的情况下在滚动视图中按下一个按钮

在UITableview Header和UITableView Footer中的UIScrollView上禁用了UserInteraction,并且只有在正文滚动时才会滚动。

在我的头文件中,我现在有一个位于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; 
} 

回答

1

当用户交互是在视图上被禁用,还可以防止触摸事件被向下传​​递给其子视图。您需要在滚动视图上启用userInteraction才能点按按钮。您可以将isScrollEnabled设置为false,以防止滚动视图滚动。

+0

谢谢你......这很好 – Burnie777

相关问题