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

[亡魂溺海] 提交于 2019-12-07 04:29:24

问题


EDIT: Since I haven't installed XCode 4 yet, I would like to know if MD 2.8 is fully compatible with XCode 3.2.6 or not. In particular, Am I able to connect Outlets and Actions with the new procedure described in MT documentation?

I've just installed MonoDevelop (MD) 2.8. It seems not working I was expecting.

In MD 2.6 when I create a new UIViewController, that controller is presented like the following:

  • Controller.xib <- inside the same tree
    • Controller.xib.cs
    • Controller.xib.designer.cs

In addition if I open a xib file, Controller.xib, only Interface Builder (IB) is opened. If I add outlets to the xib, the outlets are visible in the Controller.xib.designer.cs.

In MD 2.8 when I create a new UIViewController, that controller is presented like the following:

  • Controller.xib <- no more inside the same tree
  • Controller.cs
    • Controller.designer.cs

So I have two files instead of one.

In addition if I open a xib file, Controller.xib, IB and Xcode are opened. If I add outlets to the xib, the outlets aren't visible in the designer.

Any suggestions?


回答1:


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



来源:https://stackoverflow.com/questions/7698167/monodevelop-2-8-xcode-3-2-6-interface-builder-outlets-and-actions

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