swift - 在 Swift 中创建下拉菜单
问题描述
我想快速创建一个下拉列表,尝试以下代码:
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”。我该如何解决?
解决方案
推荐阅读
- swift - macOS Safari 内容阻止应用扩展中的上下文菜单
- ios - 从 iOS 项目调用时的领域异常
- amazon-web-services - Express lambda 从 api 调用返回 JSON
- java - 在命令设计模式中将上下文传递给执行方法
- php - 在 PHP 中将多索引 Excel 文件转换为数组
- javascript - 在页面上重新加载特定的 div 而不在 rails 中刷新页面
- python-2.7 - 如何在 python 2.7 中使用 selenium 模块打开 Web 浏览器?
- python - 如何将自定义标签/过滤器添加到现有的 Django 应用程序?
- python - 从python中的网页中提取所有表
- kubernetes - 当节点死亡/重新启动并具有 PersistentVolume 时的 StatefulSet 行为