【问题标题】:iOS 11 : Crash with UIScrollViewiOS 11:UIScrollView 崩溃
【发布时间】:2018-03-03 06:09:03
【问题描述】:

在 iOS 11 中,当我推送包含滚动视图的 ViewController 时,我的应用程序崩溃。为什么?

要推送的代码:

let programViewController = self.storyboard?.instantiateViewController(withIdentifier: "ProgramViewController") as? ProgramViewController
self.navigationController?.pushViewController(programViewController!, animated: true)

错误:

-[UIViewadjustedContentInset]:无法识别的选择器发送到实例 0x7fca395ed440 2017-09-21 21:01:53.203465+0200 ApplicationName[1980:45337] *** 由于未捕获而终止应用程序 异常'NSInvalidArgumentException',原因:'-[UIView adjustedContentInset]:发送到实例的无法识别的选择器 0x7fca395ed440'

代码:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let cell = tableView.cellForRow(at: indexPath)
    switch self.typeContent {
    case "news" :
        let listNews = self.listObjects as! [NewsArticle]
        let webViewController = self.storyboard?.instantiateViewController(withIdentifier: "WebViewController") as? WebViewController
        webViewController!.url = listNews[(indexPath as NSIndexPath).section].link
        self.navigationController?.pushViewController(webViewController!, animated: true)
    case "program":
        let part = self.listObjects[indexPath.section] as! ProgramPart
        let event = part.listEvents[indexPath.row]
        let programViewController = self.storyboard?.instantiateViewController(withIdentifier: "ProgramViewController") as? ProgramViewController
        programViewController?.paramsList = ["event_id": "\(event.id)"]
        programViewController?.delegate = cell as? FollowEventDelegate
        self.navigationController?.pushViewController(programViewController!, animated: true)
    default :
        break;
    }
}

【问题讨论】:

  • 上面的push action写成button action?
  • 否,选择TableViewCell时。 span>
  • 所以你是用 didSetRowAt Index 方法写的。能分享一下你的代码吗?
  • 什么堆栈框架试图调用-[UIView adjustedContentInset]
  • 您的故事板中似乎有些东西应该是UIScrollView,但实际上是一个普通的旧UIView

标签: ios swift uiscrollview ios11


【解决方案1】:

确实,在我的 UIScrollView 中,我有一个包含所有其他 UIView 的 UIView。所以我把它删除了,把所有的 UIView 直接放到 UIScrollView 中,我预先告别了更多来处理约束。 感谢 Rmaddy 带我回答这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-10
    • 1970-01-01
    • 1970-01-01
    • 2018-05-04
    • 2013-03-24
    • 1970-01-01
    • 2018-03-25
    • 2018-03-15
    相关资源
    最近更新 更多