Unable to connect IBOutlet from storyboard to UIView subclass

前端 未结 9 809
旧巷少年郎
旧巷少年郎 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:42

    Create an outlet like this in Objective-C

    @property (nonatomic, weak) IBOutlet UIView *view;
    

    or as in swift 3

    @IBOutlet weak var instruction: UILabel?
    

    and then connect it as given in this image.

    Sometimes the normal way of connecting action and outlet doesn't work due to subclassing. This way comes handy for such situations.

提交回复
热议问题