【发布时间】: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