大佬教程收集整理的这篇文章主要介绍了uitableview – 启动应用程序xCode时的EXC_BAD_INSTRUCTION断点,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
func tableView(tableView: UITableView!,cellForRowATindexPath indexPath: NSIndexPath!) -> UITableViewCell! { // Configure the cell... let cellId: NSString = "Cell" var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(cellId) as UITableViewCell }@H_696_5@它在var cell的行上崩溃了 @H_696_5@它给出以下错误: @H_696_5@我无法弄清楚我的代码有什么问题. @H_696_5@整个功能: @H_696_5@
func tableView(tableView: UITableView!,cellForRowATindexPath indexPath: NSIndexPath!) -> UITableViewCell! { // Configure the cell... let cellId: NSString = "Cell" var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(cellId) as UITableViewCell let data: NsmanagedObject = mylist[ip.row] as NsmanagedObject cell.textLabel.text = data.valueForKeyPath("voornaam") as String cell.detailTextLabel.text = data.valueForKeyPath("achternaam") as String return cell }@H_696_5@编辑:
func tableView(tableView: UITableView!,cellForRowATindexPath indexPath: NSIndexPath!) -> UITableViewCell? { // Configure the cell... let cellId: NSString = "Cell" var cell: UITableViewCell? = tableView?.dequeueReusableCellWithIdentifier(cellId) as? UITableViewCell if cell == nil { cell = UITableViewCell(style: .Subtitle,reusEIDentifier: cellId) } let data: NsmanagedObject = mylist[indexPath.row] as NsmanagedObject cell!.textLabel.text = data.valueForKey("voornaam") as String cell!.detailTextLabel.text = data.valueForKey("achternaam") as String //cell!.textLabel.text = "Hoi" return cell }
var cell: UITableViewCell? = tableView.dequeueReusableCellWithIdentifier(cellId) as? UITableViewCell if cell == nil { cell = UITableViewCell(style: .Subtitle,reusEIDentifier: cellId) } ...@H_696_5@因为单元格现在是可选值,请使用单元格!当你想调用它上面的方法来强制解包其中的UITableViewCell. @H_696_5@此外,您的代码还有第二个问题:它从未创建过新的单元格. dequeue将在第一次在表视图中调用时返回nil.您需要在我的代码示例中实例化一个新的UITableViewCell,然后从cellFor …方法返回它.然后,表视图将保存单元格并在将来调用时将其返回到队列.
以上是大佬教程为你收集整理的uitableview – 启动应用程序xCode时的EXC_BAD_INSTRUCTION断点全部内容,希望文章能够帮你解决uitableview – 启动应用程序xCode时的EXC_BAD_INSTRUCTION断点所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。