How to link ibOutlet from subview to custom UIView Class in storyboard xcode

岁酱吖の 提交于 2019-12-04 00:19:10

Here is a solution:

1) Type an IBOutlet by hands in your header file, example:

@property (strong, nonatomic) IBOutlet ProgressBarElementView *targetProgressElement;

2) Drag the pin from the code to the element in document outline zone

I have the same problem.. I saw that if you add the custom class to the root view in the view controller, it will work.. In your case this is the initial View, listed under Bottom Layout Guide

But there must be a better way

To overcome XCode stubborness, especially when you need to hook up different enums from UIControlEvent than UIControlEventTouchUpInside, I'd rather use code directly from within the custom view class:

SWIFT

button.addTarget(self, action:#selector(ClassName.handleRegister(sender:)),
                          for: .touchDragExit)

OBJECTIVE-C

[self.button addTarget:self
                action: @selector(buttonTouchDragExitAction:)
      forControlEvents:UIControlEventTouchDragExit];

One might include such code in awakeFromNib or viewDidLoad or where it best suits.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!