我在使用此代碼添加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);
}
的問題是,點擊按鈕時,我得到的值,是最後一個按鈕的加入。
我該如何解決這個問題?