• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Xamarin .苹果个人计算机演练教程中单击按钮事件处理函数不生效的病菌


Recommended Posts

参考

学习教程

环境

mac os 12.3.1

visual studio for mac 2019

xcode 13.3.1

点网6.0.202

问题与解决办法

根据官网教程学习将代码复制到文件中

下一步,添加代码以对用户点击按钮作出响应。将下面的分部方法添加到视图控制器类:

局部无效单击按钮(基础…n。对象发件人){

//更新计数器和标签

单击标签StringValue=字符串。格式('该按钮已被单击{0}次{1} '。numberOfTimesClicked,(numberOfTimesClicked 2)?‘‘:’s’);

}

此代码会附加到在Xcode和界面生成器中创建的操作,且每次用户点击按钮时都会调用此代码。

2.代码提示错误

未找到用于实现分部方法"视图控制器"声明的定义声明。'单击按钮' n对象'

解决办法将官网代码替换为下面的代码,出错原因就是部分类 partial 的定义需要一致,因为C#基础不好,所以会因为这个问题出错

部分void ClickedButton(应用套件.按钮发送器)

{

//更新计数器和标签

单击标签StringValue=字符串。格式('该按钮已被单击{0}次{1} '。numberOfTimesClicked,(numberOfTimesClicked 2)?‘‘:’s’);

}

Link to comment
Share on other sites