【发布时间】:2020-05-02 19:41:26
【问题描述】:
我正在尝试添加一个按钮,允许用户刷新表格视图并将它们带回表格顶部。我正在尝试添加一个设置了类似 var layoutGuide:UILayoutGuide! 的 var 的代码的 sn-p,但它给了我这个消息。 然后我尝试运行模拟器并简单地忽略此消息,但随后我收到一条错误消息,说它在解包时找到了一个可选值 nil。 关于为什么会发生这种情况的任何想法?谢谢
【问题讨论】:
-
你应该使用
let layoutGuide = UILayoutGuide() -
@byaruhaf 我使用了你的方法并且它运行了,但现在我收到了这个错误
Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutYAxisAnchor:0x600000538880 "new_app_3.SeeNewPostsButton:0x7fe15853d9f0.top"> and <NSLayoutYAxisAnchor:0x600000538f00 "UILayoutGuide:0x6000029e0a80''.top"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal. -
@PhillipMills 谢谢你的链接,这是很好的信息。
标签: swift xcode fatal-error