信息
我正在使用 Xamarin Studio 和 Xcode。
我的两个按钮“IncreaseButton”和“DecreaseButton”都将它们发送的事件“TouchUpInside”附加到我的 IBAction 'buttonClick' 上。
下面的代码将在部分 void buttonClick 函数中生成 2 个错误;但是,我的问题是如何在实现我在下面的代码中实现的目标的同时不产生这 2 个错误(如果这有意义的话)。
谢谢。
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace Allah
{
public partial class AllahViewController : UIViewController
{
protected int clickCount;
public AllahViewController () : base ("AllahViewController", null)
{
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.IncreaseButton.TouchUpInside += (sender, e) => {
this.clickCount++;
};
this.DecreaseButton.TouchUpInside += (sender, e) => {
this.clickCount--;
};
// Perform any additional setup after loading the view, typically from a nib.
}
partial void buttonClick (NSObject sender)
{
if (this.IncreaseButton.TouchUpInside == true)
{
this.CountLabel.Text = clickCount.ToString();
}
if (this.DecreaseButton.TouchUpInside == true)
{
this.CountLabel.Text = clickCount.ToString();
}
}
}}