Unable to connect IBOutlet from storyboard to UIView subclass

前端 未结 9 772
旧巷少年郎
旧巷少年郎 2020-12-05 10:11

I am able to right-click and drag from my custom UIView subclass file to the storyboard elements to connect them, but unable to do so the other way around. I believe this is

9条回答
  •  失恋的感觉
    2020-12-05 10:40

    Things to check if IBOutlet does not connect:

    1. Is the class defined in storyboard?

      Select the UIViewController in storyboard, then on the right side of the screen, select the identity inspector and assign the appropriate class.

    2. Are the type of outlet you defined match the one on storyboard? For example, we connect UIButton, then the outlet should look like that, write the code for the outlet, then connect to the view controller:

      @IBOutlet weak var theButton: UIButton!
      

提交回复
热议问题