I'm going through the appcoda's beginning iOS 12 programming with swift book. I'm trying to establish a connection between a UIView subclass and IBOutlets but for some reason I'm not able to. I created a file with a new subclass and also changed the custom class in the identity inspector but I don't see any of the outlets in the connections inspector?
Asked
Active
Viewed 61 times
0
-
1did you set the `@IBOutlet` in code – Yoel Jimenez del valle Jul 22 '19 at 22:51
-
1In your assistant editor, under automatic, do you see the custom class in the list? If not, double check the name of your class to make sure it matches the one in the identity inspector. – rs7 Jul 22 '19 at 23:25
-
@kjoe Yes, I did. – newiosdeveloper Jul 23 '19 at 00:17
-
@rs7 I don't see the custom class and I just checked again, the class name matches. – newiosdeveloper Jul 23 '19 at 00:19
-
Here's the a link with images: https://www.reddit.com/r/iOSProgramming/comments/cgkr8v/cant_establish_connection_between_uiview_subclass/ – newiosdeveloper Jul 23 '19 at 00:20
-
control-drag from that empty circle to the left of your IBOutlets to the appropriate object in your document outline. The line should be blue if you've selected it correctly. – Don Jul 23 '19 at 01:13
-
@Don I've tried that too. It doesn't work. – newiosdeveloper Jul 23 '19 at 01:43
-
What happens when you control-drag from the document outline into the class? – Don Jul 23 '19 at 01:51
-
@Don I'm able to control-drag from the document online into the class but it doesn't conform to the class. It conforms to the UIView class instead of the subclass. – newiosdeveloper Jul 23 '19 at 01:55
-
I would try 3 things. First, place the caret at the end of your subclass name in the identity inspector and hit the return key. Xcode can be finicky and I always hit return after setting a custom class. Second, I would close Xcode, reopen and retry the control-drag. Last, I would delete the class and start over. – Don Jul 23 '19 at 02:00
-
@Don I tried what you recommened on a test project it worked but for some reason it's not working on my project – newiosdeveloper Jul 23 '19 at 02:19
-
You could try Product->Clean Build Folder. I'm kind of out of ideas. I have only encountered this situation a couple times, so I'm sorry it's happening to you if you're just beginning. – Don Jul 23 '19 at 02:25
-
@Don I did that too. It's kinda weird because I have a custom cell in my project and that worked completely fine but for some reason it's having an issue with UIView – newiosdeveloper Jul 23 '19 at 02:27
-
In the view's identity inspector, is "Inherit Module from Target" checked? – rs7 Jul 23 '19 at 02:39
-
@rs7 yes, it is. I've done everything that's been recommended but nothing works. Is there something else that I can use instead of UIView. – newiosdeveloper Jul 23 '19 at 02:43
-
Seems like it's a bug. Look at this thread: https://stackoverflow.com/questions/40932172/unable-to-connect-iboutlet-from-storyboard-to-uiview-subclass – rs7 Jul 23 '19 at 02:54
-
Try dragging from the subclass file to storyboard instead of the other way around: https://stackoverflow.com/questions/28052924/how-to-link-iboutlet-from-subview-to-custom-uiview-class-in-storyboard-xcode – rs7 Jul 23 '19 at 02:55