我在使用此代码添加UIButtons for循环按钮:MonoTouch的添加在for循环
for (int i=0; i <12; i++) {
button = new UIButton(new RectangleF(xBase + i * 25,100 + i,25,25));
button.SetBackgroundImage(UIImage.FromBundle ("Images/b.png"),UIControlState.Normal);
button.TouchUpInside += (s, e) => {
UIAlertView alert = new UIAlertView("",i.ToString(),null,"",null);
alert.Show();
};
this.Add (button);
}
的问题是,点击按钮时,我得到的值,是最后一个按钮的加入。
我该如何解决这个问题?