我想快速创建一个下拉菜单,尝试以下代码:
import UIKit
class DataUser: UIViewController {
@IBOutlet weak var btnDtop: UIButton!
@IBOutlet weak var tblView: UITableView!
var movinghouses = ["apple","coooasnk","scnaon","dojcncn"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func onClickDropButton(_ sender: Any) {
}
}
extension DataUser : UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return movinghouses.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = movinghouses[indexPath.row]
return cell
}
}
执行此操作时,代码中出现错误,指出:“线程1:信号SIGABR”。 我该如何解决?
答案 0 :(得分:0)
SIGABRT错误通常是UI元素和插座之间连接断开的结果。尝试清理项目,如果不起作用,请检查UIButton的连接,并确保未更改或删除它们。有关如何执行此操作的更多信息,请参见this post或this article。