Search code examples
iosswiftxcodeuiscrollview

Crash when has IBOutlet connection contentScrollView in Storyboard


In a Storyboard, I have an initial UIViewController (FirstViewController) that Present Modally one UINavigationController with a root UIViewController (SecondViewController).

This SecondViewController Show (e.g. Push) another UIViewController (ThirdViewController) that has a UIScrollView with a UIView, that I place my content/components (I called contentScrollView).

In this ThirdViewController, I put all constraints (top, leading, bottom, trailing) in ScrollView to margin 0 with the superView and the contentScrollView to margin 0 with the superView (that is the ScrollView) and to equals Height and Width to the ScrollView. In the Height constraint I set low priority to Xcode not show an error in constraints.

When I made an IBOutlet with this contentScrollView to my ThirdViewController.swift, my app crash in run time when I enter in the ThirdViewController.

I don't know what I'm doing wrong, if is the constraints, or another configuration.

The app crash with this log: "[UIView refreshControl]: unrecognized selector sent to instance ..."

When I Present Modally this ThirdViewController, this bug don't occur.

I made an example project to simulate this bug: https://gitlab.com/lucas_foton/bugscrollview


Solution

  • You don't need to connect IBOutlet for contentScrollView so just remove it and your project won't crash.

    EDIT:

    Looks like problem is with contentScrollView name you gave to IBOutlet if I changed it to contentView and it's working fine.