gpt4 book ai didi

uiviewcontroller - 是否可以在 UIViewController 的子类中实现 topLayoutGuide 和 bottomLayoutGuide?

转载 作者:行者123 更新时间:2023-12-04 12:48:04 24 4
gpt4 key购买 nike

我一直在尝试创建一个容器 View Controller ,它提供一些覆盖 View ,如 UINavigationController 和 UITabBarController 为 iOS 7 中的 View Controller 做的。为了使包含的 View 布局正确,我已经尝试了几乎所有我能想到的关于实现-bottomLayoutGuide 在容器和包含的 View Controller 中,但没有运气。该方法被调用,但该值似乎没有被使用。

我在 https://github.com/stefanfisk/custom-layout-guides 上整理了一个简单的示例。 ,但是我什至无法调用访问器。

最佳答案

我发现当您在代码中设置约束时,例如

[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:[topLayoutGuide][mainView]"
options:0
metrics:nil
views:@{@"topLayoutGuide" : self.topLayoutGuide, @"mainView" : self.mainView}]];

它崩溃了:
2013-10-16 22:23:27.119 Custom Layout Guides[46840:a0b] -[LayoutGuide superview]: unrecognized selector sent to instance 0x8c80c80
2013-10-16 22:23:27.124 Custom Layout Guides[46840:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LayoutGuide superview]: unrecognized selector sent to instance 0x8c80c80'

奇怪的是自动布局尝试调用 superview在布局指南上,因为它应该只符合 UILayoutSupport协议(protocol)。

我还注意到 topLayoutGuide & bottomLayoutGuide被声明为 readonly :
@property(nonatomic, readonly, retain) id<UILayoutSupport> topLayoutGuide
@property(nonatomic, readonly, retain) id<UILayoutSupport> bottomLayoutGuide

关于uiviewcontroller - 是否可以在 UIViewController 的子类中实现 topLayoutGuide 和 bottomLayoutGuide?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19411676/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com