2017-06-15 59 views
1

我创建了一个UIViewController,它包含两个View(顶部,底部), 底部视图在单击searchBar时一直展开到顶部。 (bottomView高度扩大,topView高度越来越小)。didSelectRowAt indexPath没有被调用

func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool { 
    self.expandBottomView() 
    return true 
} 

func expandBottomView() { 
    let heightToAdd = TopView.frame.height - numOfRequestsTitle.frame.height 

    RecomandFriendHeight.constant += heightToAdd 
    UIView.animate(withDuration: 0.5) { 
     self.view.layoutIfNeeded() 
    } 

    topTableView.isUserInteractionEnabled = false 
} 

这两个视图都包含TableViews(topTableView,BottomTableView)所有代表都被设置了我检查。 BottomView包含另一个按钮以在需要时折叠bottomView。

topTableViewCell包含两个按钮和两个标签。 bottomTableViewCell包含一个标签和一个imageView。

问题是没有一个tableViews单元调用didSelectRowAt。 enter image description here

+0

要被代表设置什么课? – CoderFrom94

+0

到包含topView和bottomView的UIViewController。 –

+0

你能提供更多的代码吗?我希望看到为tableViews和didSelectRowAt方法声明都设置了委托和数据源。 – CoderFrom94

回答

0

如果将按钮添加到单元格didSelectAt未点击按钮调用。在这种情况下,你必须选择添加到该按钮内cellForRowAt:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! customcell 
     cell.btn.addTarget(self, action: #selector(clickedCell), for: .touchUpInside) 
     return cell 

    } 

,并实现该选择方法

func clickedCell(_ sender : UIButton) { 
     print("clicked") 
} 
0


topTableView.isUserInteractionEnabled = true

相关问题