【问题标题】:crossplatform in XamarinXamarin 中的跨平台
【发布时间】:2013-12-13 15:58:38
【问题描述】:

iOS in Xamarin

Post来自 Zecht1 » 2013 年 12 月 13 日星期五 1:26 pm 嗨

我刚刚开始学习Xamarin,我正在关注他们网站上的教程http://docs.xamarin.com/guides/android/getting_started/hello,_world/

我有一个问题,我需要一些帮助!

教程里说我应该这样写代码:

partial void actnButtonClick (MonoTouch.Foundation.NSObject sender)
{
    this.lblOutput.Text = "Action button " +  ((UIButton)sender).CurrentTitle + " clicked.";
}

但这对我不起作用。我只是得到一个错误。

我的看起来像这样:

partial void actnButtonClick (MonoTouch.Foundation.NSObject sender);

我是不是做错了什么???

错误信息:

http://s23.postimg.org/mp1niokij/Screen_Shot_2013_12_13_at_5_09_07_PM.png

http://s2.postimg.org/fy5n9im95/Screen_Shot_2013_12_13_at_5_09_29_PM.png

【问题讨论】:

  • 你得到什么错误?

标签: c# android iphone xamarin.ios xamarin


【解决方案1】:

编辑:添加截图后删除原始答案。

您添加了屏幕截图后,我发现了问题。您不能修改 .designer.cs 文件。它甚至在您放置的屏幕截图的顶部说,“可能无法正确处理对此文件的手动更改。”

我不知道您将文件命名为什么,但假设主文件名为 HelloWorld.cs,您需要进行以下更改:

HelloWorld.designer.cs:

[Action ("acOneBtnClick:")]
partial void acOneBtnClick(MonoTouch.Foundation.NSObject sender);

这部分应该由 Xamarin 自动创建。

HelloWorld.cs:

partial void acOneBtnClick(MonoTouch.Foundation.NSObject sender)
{
    this.ibiOutput.Text = "Action button" + ((UIButton)sender).CurrentTitle + " clicked.";
}

声明为partial 的方法和类可以在单独的文件中实现。请参阅MSDN partial (Method) 了解更多信息。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2018-10-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-04
相关资源
最近更新 更多