在Storyboard
中,我有一个初始UIViewController
(FirstViewController
),该词首字母为UINavigationController
,根为UIViewController
(SecondViewController
)。
此SecondViewController
显示(例如,推送)另一个具有UIViewController
和UIView的ThirdViewController
(UIScrollView
),我放置了内容/组件(我称为{ {1}}。
在此contentScrollView
中,我使用superView将ThirdViewController
中的所有约束(顶部,前导,底部,尾部)放置在边缘0,使用{{ 1}}(即ScrollView
),并且等于contentScrollView
的高度和宽度。在“高度”约束中,我将Xcode的优先级设置为低,不显示约束错误。
当我使用此superView
到ScrollView
。swift中创建一个ScrollView
时,当我输入IBOutlet
时,我的应用在运行时崩溃。
我不知道我在做什么错,是约束还是其他配置。
应用程序崩溃,并显示以下日志:“ [{contentScrollView
]:无法识别的选择器已发送到实例...”
当我模态呈现此ThirdViewController
时,不会发生此错误。
我制作了一个示例项目来模拟此错误:https://gitlab.com/lucas_foton/bugscrollview
答案 0 :(得分:0)
您不需要为IBOutlet
连接contentScrollView
,因此只需删除它,您的项目就不会崩溃。
编辑:
如果我将其更改为contentScrollView
,那么您给IBOutlet
命名的contentView
可能就是问题所在,并且工作正常。