Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect UIView outlets to a custom subview

Tags:

xcode

ios

I'm still new to xcode / iOS and have the following problem:

in order to display some mobile debug information, I have a UIview added/connected as outlet-property to one of my Viewcontroller. This view is a custom subclass of UIview. Now I addeddd some UIlabels as sub views to this view and want to drag the outlet connections from these labels to my customUIview.h file in order to have these labels accessible as properties of my custom UIview class (no need to access them directly from the view Controller).

Problem is that the interface builder (I'm using Storyboards/ xcode4.3) does not make the trick. I can connect the outlets to the ViewControllerClass.h but not to my sub view's .h file. Can anyone point out where the problem is?

like image 370
user1702623 Avatar asked Oct 19 '12 13:10

user1702623


People also ask

How to add custom view to storyboard?

Using a custom view in storyboardsOpen up your story board and drag a View (colored orange below for visibility) from the Object Library into your view controller. Set the view's custom class to your custom view's class. Create an outlet for the custom view in your view controller.

How do I load a view in Swift?

In the XIB, I changed the "File's Owner" class to SomeView (in the identity inspector). I created a UIView outlet in SomeView. swift, linking it to the top level view in the XIB file (named it "view" for convenience). I then added other outlets to other controls in the XIB file as needed.


1 Answers

Just solved the problem. After typing the property outlet declarations manually in the customview.h file I could ctrl-drag-connect them from there to their corresponding UIlabel objects in the interfacebuilder. Works only in this direction!

Thanks anyway

like image 68
tib Avatar answered Sep 20 '22 06:09

tib