UITableView inside UIScrollView not receiving first tap after scrollling

前端 未结 14 1798
北海茫月
北海茫月 2020-11-29 04:31

Brief

I am having an issue with a UITableView inside a UIScrollView. When I scroll the external scrollView, the table<

14条回答
  •  -上瘾入骨i
    2020-11-29 05:14

    1. Drop a UIButton over your UITableViewCell and create the outlet as "btnRowSelect".
    2. In your view controller put this code in cellForRowAtIndexPath

      cell.btnRowSelect.tag = indexPath.row
      cell.btnRowSelect.addTarget(self, action: Selector("rowSelect:"), forControlEvents: .TouchUpInside)
      
    3. Add this function to your viewController as well-

      func rowSelect (sender:UIButton) {
      // "sendet.tag" give you the selected row 
      // do whatever you want to do in didSelectRowAtIndexPath
      }
      

    This function "rowSelect" will work as didSelectRowAtIndexPath where you get the row"indexPath.row" as "sender.tag"

提交回复
热议问题