xamarin.ios - Not able to add UIbutton to UIscrollview in Monotouch Dynamically -


i facing strange problem. trying add uibuttons uiscrollview in monotouch. uibutton not getting displayed.

here code:

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); 

the same code works if add button view. can on please.

i tried following code after adding uiscrollview view in interface builder:

    uiimage img = uiimage.fromfile("ecu.png");         uibutton btn = uibutton.fromtype(uibuttontype.custom);         btn.setbackgroundimage(img,uicontrolstate.normal);         btn.frame = new rectanglef(0.0f, 0.0f, 150.0f, 150.0f);         btn.touchupinside += (sender, e) => {             uialertview alert = new uialertview("info","tapped",null,"ok",null);             alert.show();         } ;         this.scrollimages.addsubview (btn); 

and works expected. odd thing seems have 7 parameters rectanglef constructor. have tried setting origin 0,0 see if button added there?


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -