ios - 无法将类型 'to_do_list.AddItemViewController' (0x1009f3970) 的值转换为 'to_do_list.ListDetailViewController' (0x1009f3850)

标签 ios iphone xcode swift

我创建了一个列表,其中我提供了一个用于编辑列表的详细信息披露按钮,但是当我点击这个按钮时它显示了一个错误

Could not cast value of type.

这是我的代码:

  override func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath)
{

    let navigationController = storyboard!.instantiateViewControllerWithIdentifier("ListNavigationController") as! UINavigationController

    let controller = navigationController.topViewController as! ListDetailViewController

    controller.delegate = self

    let checklist = dataModel.lists[indexPath.row]

    controller.checklistToEdit = checklist

    presentViewController(navigationController, animated: true, completion: nil)

}

最佳答案

我分析了您的项目并建议您删除所有不需要的导航 Controller 并将此代码添加到您的 accessoryButtonTappedForRowWithIndexPath 方法中:

let VC = storyboard!.instantiateViewControllerWithIdentifier("ListNavigationController") as! ListDetailViewController

self.navigationController?.pushViewController(VC, animated: true)

关于ios - 无法将类型 'to_do_list.AddItemViewController' (0x1009f3970) 的值转换为 'to_do_list.ListDetailViewController' (0x1009f3850),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31826728/

相关文章:

iphone - 释放 Root View Controller

ios - 防止 UIDatePicker 变得太宽

iphone - 关闭特定对象的控制台日志记录

iphone - 我如何通过iphone开发存储来自SQLite数据库的数据

ios - 委托(delegate) VS IBAction 处理事件 iOS

ios - Firebase 动态链接无效并被阻止

android - 使用android:versionCode和Bundle版本> 1发布Android Market和iOS应用商店的应用?

iphone - UIView animateWithDuration 立即返回

ios - 在 Xcode 9(测试版)中将 pod 与 Playgrounds 结合使用

ios - 针对 ios6.1 编译的 Xcode 5 不保留布局