首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIview中的致命错误两个表视图

UIview中的致命错误两个表视图
EN

Stack Overflow用户
提问于 2016-02-22 14:22:02
回答 1查看 47关注 0票数 0

在我的应用程序中,我想在UIViewController中显示两个表视图,但是我有一个致命的错误:致命错误:意外地找到零,而打开一个可选的值

有人能帮我吗?

这是uiview的完整代码

类MyPropertiesViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

代码语言:javascript
复制
//table view extended
@IBOutlet weak var extandedTableViex: UITableView!

// table view standart
@IBOutlet weak var standartTableView: UITableView!
//list of data
let stdlist = ["1","2","3", "4","5","6","7","8","9"]

let Extlist = ["E1","E2" ]

//单元标识符让stdcellIdentifier = "stdcell“

代码语言:javascript
复制
let extcellIdentifier = "extcell"

override func viewDidLoad() {
    super.viewDidLoad()
    standartTableView.delegate = self
    standartTableView.dataSource = self

    standartTableView.delegate = self
    standartTableView.dataSource = self

    standartTableView.scrollEnabled = false
    extandedTableViex.scrollEnabled = false

    self.standartTableView.registerClass(GuaranteeCell.self, forCellReuseIdentifier: stdcellIdentifier)
    self.extandedTableViex.registerClass(GuaranteeCell.self, forCellReuseIdentifier: extcellIdentifier)
}

//count cell
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if tableView == standartTableView {
        return self.stdlist.count;
    } else {
        return self.Extlist.count;
    }

}

// add cell
   func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    if tableView == standartTableView {
        let cell:GuaranteeCell = self.standartTableView.dequeueReusableCellWithIdentifier(stdcellIdentifier) as! GuaranteeCell
        print("list-element " + self.stdlist[indexPath.row])
           print(indexPath.row)

        cell.guaranteeLabel.text = self.stdlist[indexPath.row]
        return cell
    } else {
        let cell2:GuaranteeCell = self.extandedTableViex.dequeueReusableCellWithIdentifier(extcellIdentifier) as! GuaranteeCell
        cell2.guaranteeLabel.text = String(self.Extlist[indexPath.row])
        return cell2  
    }
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { }

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

谢谢

EN

回答 1

Stack Overflow用户

发布于 2016-02-22 14:29:10

检查单元格类是否真的是GuaranteeCell (可能存在错误)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35556039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档