Monodevelop 2.8, XCode 3.2.6, Interface Builder: Outlets and Actions

陌路散爱 提交于 2019-12-05 10:36:51

MonoDevelop 2.8 introduced a new xib designer model in order to support Xcode 4.

The Interface Builder integrated in Xcode 4 no longer supports defining classes, outlets and actions in xib files. This measn it's no longer possible for MonoDevelop to use the model where it generated *.xib.designer.cs files from xib files. Instead, Interface Builder reads outlets and actions from Objective-C source code. MonoDevelop's solution to this is to sync C# classes to Objective-C stubs.

When you open a xib file from MonoDevelop 2.8, MonoDevelop creates a temporary Xcode project with Objective-C stubs mirroring all the C# classes that are exposed to Objective-C, i.e. the classes that inherit from NSObject and are explicitly registered with a [Register("SomeName")] attribute. It then opens the xib file in the context of that project, so that Interface Builder will see all the available types and the outlets and action on them. If outlets and actions are added in Xcode 4 using its control-drag system, those are automatically imported back into *.designer.cs files in MonoDevelop.

This means that the designer files are no longer generated from some other file, instead they are the actual location where the information is stored. Now the designer files are associated with a class instead of a xib.

This new model has several upsides on top of supporting Xcode 4:

  • It's now possible for multiple xib files refer to the same class.
  • The project contains all the content resources and other xib files, so they can easily be referenced from Interface Builder
  • Interface Builder will 'see' outlets written on C# user class parts and base classes, not just the designer class parts.

In addition, it's now much easier to write outlets manually. Simply apply the Outlet attribute to a property, for example

[Outlet ("someView")]
UIView SomeView {get; set; }

Unfortunately the new model means that MonoDevelop no longer integrates with the creation of outlets and actions in Interface Builder 3.2.x. My recommendation is that you upgrade to Xcode 4. Loading and editing of pre-MD 2.8 projects should work fine.

Please see http://docs.xamarin.com/ios/tutorials/transitioning_from_xcode_3_to_xcode_4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!