gpt4 book ai didi

ios - 如何禁用 UITableViewCell 某些部分调用 DidSelect ?

转载 作者:行者123 更新时间:2023-11-30 12:11:31 52 4
gpt4 key购买 nike

由于我的单元格可以点击展开,并且可展开部分包含两个按钮,因此我希望当用户点击这些按钮时不会调用 DidSelect/DidDeselect 以改善用户体验。

按钮放置在另一个 UIView 内的 StackView 内。

enter image description here

我尝试禁用 stackView 和 UIView 容器的 userInteraction,但结果是相同的。

您建议如何禁用整个 UIView 容器(注意这是我的单元格的一部分)在点击时调用 DidSelect/DidDeselect?

最佳答案

尝试在stackView中实现这两个按钮的操作。

// inside cellForRowAt indexPath
cell?.button1.tag = indexPath.row
cell?.button1.addTarget(self, action: #selector(defineTypeAction(_:)), for: .touchUpInside)
<小时/>

各自的行动:

func defineTypeAction (_ sender: UIButton){
let alert=UIAlertController(title: kAppName, message: "Select", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in
sender.setTitle("your title", for: .normal)
// your custom code
}));

present(alert, animated: true, completion: nil)
}

当您点击按钮时,将调用其操作方法而不是 tableView 委托(delegate)方法。

关于ios - 如何禁用 UITableViewCell 某些部分调用 DidSelect ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45998249/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com