iOS 11:UIScrollView 崩溃
iOS 11 : Crash with UIScrollView
在 iOS 11 中,当我推送包含滚动视图的 ViewController 时,我的应用程序崩溃了。为什么?
要推送的代码:
let programViewController = self.storyboard?.instantiateViewController(withIdentifier: "ProgramViewController") as? ProgramViewController
self.navigationController?.pushViewController(programViewController!, animated: true)
错误:
-[UIView adjustedContentInset]: unrecognized selector sent to instance 0x7fca395ed440 2017-09-21 21:01:53.203465+0200
ApplicationName[1980:45337] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[UIView
adjustedContentInset]: unrecognized selector sent to instance
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;
}
}
确实,在我的 UIScrollView 中,我有一个包含所有其他 UIView 的 UIView。所以我删除它以将所有 UIView 直接放入 UIScrollView 并且我预先告别更多以处理约束。
感谢 Rmaddy 让我回答这个问题。
在 iOS 11 中,当我推送包含滚动视图的 ViewController 时,我的应用程序崩溃了。为什么?
要推送的代码:
let programViewController = self.storyboard?.instantiateViewController(withIdentifier: "ProgramViewController") as? ProgramViewController
self.navigationController?.pushViewController(programViewController!, animated: true)
错误:
-[UIView adjustedContentInset]: unrecognized selector sent to instance 0x7fca395ed440 2017-09-21 21:01:53.203465+0200 ApplicationName[1980:45337] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView adjustedContentInset]: unrecognized selector sent to instance 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;
}
}
确实,在我的 UIScrollView 中,我有一个包含所有其他 UIView 的 UIView。所以我删除它以将所有 UIView 直接放入 UIScrollView 并且我预先告别更多以处理约束。 感谢 Rmaddy 让我回答这个问题。