tableView.rowHeight=80
btn = UIButton(frame: CGRect(x: 300, y: 0, width: 100, height: 40))
btn.setTitle(“详情”, for: .normal)
btn.backgroundColor=UIColor.red
btn .addTarget(self, action: #selector(click), for: .touchUpInside)
btn.tag=indexPath.row
cell! .addSubview(btn)
cell!.backgroundColor = UIColor.init(red: (((CGFloat)((arc4random() % 256)) / 255.0)), green: (((CGFloat)((arc4random() % 256)) / 255.0)), blue: (((CGFloat)((arc4random() % 256)) / 255.0)), alpha: 1.0);
return cell!
}
@objc func click(btu:UIButton) -> Void {
print("这是第\(btu.tag)个单元格")
}
@@这是侧滑删除
#######import UIKit
class oneViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
var dataList:[String]?
var tableView:UITableView?
override func loadView() {
super.loadView()
}
override func viewDidLoad() {
super.viewDidLoad()