Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IB Designables gives strange warning when using a custom class

I am trying to subclass my UIButton on my Storyboard with a custom swift class that should show the button as a custom Hamburger Button.

I am getting this warning and not seeing the Hamburger button being rendered in Interface Builder, although it will intermittently work.

The Custom class is called NTHamburgerButton, I don't know why the string on characters is appearing before the class name.

IB Designables: Using class UIButton for object with custom class because the class _TtC6CProjectName17NTHamburgerButton does not exist.

like image 388
Codermonk Avatar asked Jun 22 '15 19:06

Codermonk


3 Answers

I've encounter the same problem, and I found an answer from other question: enter link description here

I just Refresh All Views enter image description here

It works to me. Hope it helps you too.

like image 50
funclosure Avatar answered Oct 17 '22 01:10

funclosure


This question seems to be getting some attention again so I'll give an update.

This issue existed in a Obj-C and Swift mixed project. So the Class in question was a Swift Class.

When making Swift classes available in Obj-C, you can use the following syntax

@objc(NTHamburgerButton) public class NTHamburgerButton : UIButton {}

Otherwise in your {Project-Name}-Swift.h file that Xcode Creates you will see that it generates these unique class names like that from the question.

The only real issue here was that the NTHamburgerButton.swift file was not being included in the Product I was looking at the at time, but if I switched targets, it worked fine. Thus the intermittent issue.

like image 6
Codermonk Avatar answered Oct 17 '22 02:10

Codermonk


For me both solutions of Codermonk and specialvict was necessary, but not enough.

I also had to turn on Inherit From Target in Interface Builder:

enter image description here

This did the trick for me.

like image 5
Daniele Ceglia Avatar answered Oct 17 '22 03:10

Daniele Ceglia