swfit的tableview下拉刷新,点击cell异常,弹窗UIAlertController

xiaoxiao2021-02-28  100

1、tableview的下拉刷新问题,其实很简单利用了了一个控件refreshcontrol,在viewdidload中写下如下代码          var refreshControl=Refreshview()     refreshControl.addTarget(self, action: #selector(ViewController.refreshData), for: .valueChanged)     refreshControl.attributedTitle = NSAttributedString(string: "下拉刷新数据")     hardwarelisttable.addSubview(refreshControl) 然后再新创建一个function     func refreshData() {                  //data更新         refreshdata()         //更新数据源         self.hardwarelisttable.reloadData()                  //刷新结束         self.refreshControl.endRefreshing()     } 2、tableview中任意一个点击后会使控件一直呈现选中状态知道其他cell被选中,一直找不到原因,明明最开始都是好好的,结果一段时间就发生这种状况,后来在cell的点击事件函数中如下写到,解决     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {         //关键句         tableView.deselectRow(at: indexPath, animated: true)                             } 3、弹出提示窗口UIAlertController     //弹出提示框     //提示框中心文本         let alertController = UIAlertController(title: "系统提示",                                                 message: "您确定要删除该设备吗?", preferredStyle: .alert)         let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: nil){         //点击取消后执行     }         let okAction = UIAlertAction(title: "好的", style: .default, handler: {             action in             //点击确定后执行             print((co["id"])as! String)             print("aaaaa啊啊啊啊啊啊啊")             self.addhard(hardid: (co["id"])as! String)             self.refreshData()                                   })     //添加控件进入提示框         alertController.addAction(cancelAction)         alertController.addAction(okAction)     //显示提示框         self.present(alertController, animated: true, completion: nil)
转载请注明原文地址: https://www.6miu.com/read-49258.html

最新回复(0)