How to Connect Iboutlet from Storyboard to Uiview Subclass

Unable to connect IBOutlet from storyboard to UIView subclass

After trying some of the given solution what finally worked is by restarting the my macbook. It seems like a bug on XCode's side. Oh well.

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

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

Sample Image

Cannot connect IBOutlet to a UIViewController (or subclass thereof)

You should do this by code. And not with IBOutlets.

First: set a storyboard ID to each of the UIViewControllers.

Second:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier :"blueViewController") as! UIViewController

And connect it to a property.

You do this for all three UIViewControllers.

Is it possible to create an @IBOutlet in a custom view?

If you want to reuse a UIView then best to create an xib of the view and a custom class of the UIView. Then change the file owner in xib class to your custom class. Then you can drag and drop IBOutlets of the components inside the view to custom class. In the storyboard you can use the custom view and change the name of the class of view to custom view. Now drag and drop the IBOutlets from the story board to UIView. You can see the tutorial video on how to do , I have made for you.
https://youtu.be/IrgH522lbfA

IBOutlet is nil, but it is connected in storyboard, Swift

The storyboard wasn't recognizing any further UI things I added to it. At run time all the references were nil. So I cleared my derived data folder and then those connections worked again.

Creating IBoutlet from UIView in custom UIView class swift

In your situation, you should connect the outlets to a view controller instead of a view.

Instead of creating a UIView subclass, you should create a UIViewController subclass:

class FrontViewController: UIViewController {

}

Next, select your view controller in the storyboard. In the Identity Inspector (select the tab with an ID card on the panel on the left), type "FrontViewController" (the name of your class) into the "Class" field.

Sample Image

Now you should be able to drag outlets to the class!



Related Topics



Leave a reply



Submit