我正面臨一個非常奇怪的問題。我正在嘗試將UIbuttons添加到Monotouch中的UIscrollview。但UIbutton沒有得到顯示。無法添加UIbutton到單擊動態中的UIscrollview動態
下面是代碼:
UIImage img = UIImage.FromFile("ecu.png");
UIButton btn = UIButton.FromType(UIButtonType.Custom);
btn.SetBackgroundImage(img,UIControlState.Normal);
btn.Frame = new RectangleF(UIScreen.MainScreen.Bounds.Size.Width - 185, 0, 185,UIScreen.MainScreen.Bounds.Size.Height, 100, 150, 150);
btn.TouchUpInside += (sender, e) => {
UIAlertView alert = new UIAlertView("Info","Tapped",null,"Ok",null);
alert.Show();
} ;
scrollimages.AddSubview (btn);
相同的代碼工作,如果我將按鈕添加到視圖。 我可以得到一些這方面的幫助。
您是否設置了UIScrollView.ContentSize? – 2013-04-05 09:16:17