0

在 XCode 和目标 c 中,如果我想在界面生成器中使用 UIGlassButton,我在头文件中放入以下行:

@class UIGlassButton;

我现在正在使用 monotouch c#。我可以使用类似的语句来导入 UIGlassButton 类吗?

我想问题变成了 Monotouch 团队是否将 UIGlassButton 移植到 C# 和 Monotouch?

4

1 回答 1

2

在 C# 中,您导入的不是类,而是命名空间。例如,类可以定义为:

namespace Ui.GlassControls
{
  public class UIGlassButton
  {
   .... // methods, properties, whatever

  }

}

在需要按钮的源文件中,您将使用:

using Ui.GlassControls; // namespace reference

....
// inside of some class
UIGlassButton ugb = new UIGlassButton();
// or
Ui.GlassControls.UIGlassButton ugb = new Ui.GlassControls.UIGlassButton();

第二种实例化方法绕过了对“using”语句的需要,因为它通过其完全限定的 namepspace.controlName 标识符来引用控件。

Note I'm not familiar with UIGlassButton specifically, so you'll have to search to figure out what assembly it's defined in, and what file you need to reference from the calling project.

于 2009-11-09T20:28:52.980 回答