【发布时间】:2017-02-10 11:30:51
【问题描述】:
应用程序在Location anchors require being paired. 上崩溃。我想修复它,但是无论我使用此视图手动测试应用程序多少次,我从未遇到过崩溃(仅在 Crashlytics 上登录)。任何人都知道这里可能出了什么问题,在什么情况下可能会发生崩溃?
属性centerYConstraint 是必需的,因为稍后它允许用户向上/向下移动视图。
MyView.m 文件的一部分。崩溃发生在设置self.centerYConstraint。
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.centerYConstraint = [self.view.centerYAnchor constraintEqualToAnchor:self.parentViewController.view.centerYAnchor
constant:self.view.center.y - self.parentViewController.view.center.y];
self.centerYConstraint.active = YES;
}
崩溃日志:
Fatal Exception: NSInvalidArgumentException
NSLayoutConstraint for <NSLayoutYAxisAnchor:0x16764ae0 "MyView:0x18e6b900.centerY">:
A constraint cannot be made from <NSLayoutYAxisAnchor:0x16764ae0 "MyView:0x18e6b900.centerY"> to a constant.
Location anchors require being paired.
【问题讨论】:
-
这个错误有点误导,但是当查看我将其约束到的锚点为零时,我得到了它。在您的情况下,这将是 self.parentViewController.view。但是根据您提供的代码,我不知道在您的情况下该视图如何为零。
-
@Borbea 谢谢,我在考虑同样的情况。目前,我已经将日志添加到这一点,打印价值并将其发布给公众。一个月后,我应该有足够的数据来找出问题所在。
-
所提出的问题缺乏足够的信息,添加赏金不会改变这一点。
标签: ios objective-c crash autolayout