【发布时间】:2013-01-29 20:11:35
【问题描述】:
我喜欢 iOS 6 中新的自动布局功能,但在将它与我的 MKAnnotationView 子类结合使用时遇到了一些麻烦。
我在初始化方法中禁用了自动调整掩码转换。
self.translatesAutoresizingMaskIntoConstraints = NO;
但是当我加载使用我的子类注释的 MKMapView 时,应用程序会抛出 NSInternalInconsistencyException。
*** Assertion failure in -[ENMapAnnotationView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. ENMapAnnotationView's implementation of -layoutSubviews needs to call super.'
我没有覆盖 -layoutSubviews,所以在我看来,Apple 的 MKAnnotationView 实现还没有为自动布局做好准备。 是否有一些聪明的方法可以解决 MKAnnotationView 中缺乏自动布局支持的问题,以便我可以在我的子类中使用自动布局?
【问题讨论】:
-
我也有同样的问题,你找到解决办法了吗?
-
最后我在不使用自动布局的情况下重写了整个内容。所以恐怕我没有解决办法。
标签: iphone ios mapkit mkannotationview autolayout