Cliffhanger
Cliffhanger

Reputation: 1237

My storyboard custom class property doesn't generate a custom class in Xamarin anymore?

I'm using Visual Studio for Mac and design my UI in a storyboard using Xcode interface builder.

I'm trying to create a custom class of a UILabel and usually I just select the control and add my custom class name in the class property in xcode, and when xcode synchronises with Xamarin, the custom class is generated as a new file in the xamarin project, but this has stopped working.

Actually is seems to have stopped syncing all together. Are there any logs that I can check to see why? I have restarted xcode. Visual Studio for Mac, cleaned the project, deleted the bin and obj folders from the active project and rebooted the machine without success.

Any tips is very much appreciated!

Upvotes: 2

Views: 714

Answers (2)

Saamer
Saamer

Reputation: 5099

I love my XCode as well! Instead of doing what you used to do, you can

  1. Open the file in Xcode interface builder as usual with the Label
  2. Find and Open the ABCViewController.h file in the other XCode window.
  3. Hold control on your keyboard, click on your label on the GUI and drag it to the ABCViewController.h file and it should prompt you to create an outlet and name the class.
  4. Save and Quit, and you should see the new Properties in your ABCViewController.designer.cs file

There's definitely a new issue after the update as you can see here as well

Upvotes: 1

NSGangster
NSGangster

Reputation: 2447

My answer is a workaround and not a true answer as this has never worked for me. I have always used Xamarin iOS Designer to create custom class, then after file generation, close xib/storyboard and reopen in Xcode Interface Builder. Double checking for [Register("ClassName"]` tag.

Select Label in iOS Designer: Select Label in iOS Designer

View -> Pads -> Properties Add Class name in Class Field: Custom class entry

Should see custom class autogenerated in SolutionExplorer: enter image description here

Ensure .designer.cs file has Register Tag: enter image description here

Now you can close the .xib in VS for Mac and reopen in Xcode. It probably won't autocomplete. But any Outlets you create will be an instance of your custom class as well as any custom attributes specified in .cs files will apply at runtime. Not as convenient as creating the custom class with Xcode but at least now you can use your custom class with Xcode Interface Builder.

Upvotes: 1

Related Questions