在iOS 11中,当我推送包含滚动视图的ViewController时,我的应用程序崩溃了。为什么呢?
推送代码:
let programViewController = self.storyboard?.instantiateViewController(withIdentifier: "ProgramViewController") as? ProgramViewController
self.navigationController?.pushViewController(programViewController!, animated: true)
错误:
- [UIView adjustedContentInset]:无法识别的选择器发送到实例0x7fca395ed440 2017-09-21 21:01:53.203465 + 0200 ApplicationName [1980:45337] ***由于未被捕获而终止应用程序 异常' NSInvalidArgumentException',原因:' - [UIView adjustContentInset]:发送到实例的无法识别的选择器 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;
}
}
答案 0 :(得分:0)
的确,在我的UIScrollView中,我有一个包含所有其他UIView的UIView。所以我删除了它以将所有UIView直接放入UIScrollView中,并且我告别了更多来处理约束。 感谢Rmaddy带我回答这个问题。