ios - xamarin c# UiScrollingView not scrolling with a vertical list of buttons -


i'm developing ios app xamarin , c# code, without designer.

i implemented uiscrollview long list of buttons follows:

var sizes = uiscreen.mainscreen.bounds;// 320, 480 .... scrollview = new uiscrollview(new cgrect(20, 200, sizes.width - 40, sizes.height - 200)); scrollview.backgroundcolor = uicolor.magenta;  view.addsubview(scrollview); 

and added list of buttons:

var m1 = new uibutton(uibuttontype.system);     m1.frame = new rectanglef(45, -50, 230, 20);     m1.settitle("beautiful way", uicontrolstate.normal);     m1.touchupinside += (sender, e) => openplayerview(playeroption.stream, "mysongurl.mp3", "beautiful way" );  var m2 = new uibutton(uibuttontype.system);     m2.frame = new rectanglef(45, -20, 230, 20);     m2.settitle("boys in sky", uicontrolstate.normal);     m2.touchupinside += (sender, e) => openplayerview(playeroption.stream, "mysongurl.mp3", "boys in sky");  var m3 = new uibutton(uibuttontype.system);     m3.frame = new rectanglef(45, 10, 230, 20);         m3.settitle("cos'é l'amor", uicontrolstate.normal);     m3.touchupinside += (sender, e) => openplayerview(playeroption.stream, "mysongurl.mp3", "cos'é l'amor");  var m4 = new uibutton(uibuttontype.system);     m4.frame = new rectanglef(45, 40, 230, 20);     m4.settitle("dancing qeen", uicontrolstate.normal);     m4.touchupinside += (sender, e) => openplayerview(playeroption.stream, "mysongurl.mp3", "dancing qeen");  var m5 = new uibutton(uibuttontype.system);     m5.frame = new rectanglef(45, 70, 230, 20);     m5.settitle("free", uicontrolstate.normal);     m5.touchupinside += (sender, e) => openplayerview(playeroption.stream, "mysongurl.mp3", "free");          scrollview.addsubview(m1);         scrollview.addsubview(m2);         scrollview.addsubview(m3);         scrollview.addsubview(m4);         scrollview.addsubview(m5); 

i need add 60 buttons, , uiscrollview not scrolls...

any idea how solve? in advance...

you need tell scroll view size of content within it, like:

scrollview.contentsize = new cgsize(uiscreen.mainscreen.bounds.width, 50 * 40); 

example:

scrollview = new uiscrollview(new cgrect(0, 0, uiscreen.mainscreen.bounds.width, uiscreen.mainscreen.bounds.height)); (var = 0; < 50; i++) {     var button = new uibutton(uibuttontype.system);     button.frame = new cgrect(40, 20 + (i * 40), 100, 40);     button.settitle("button : " + i, uicontrolstate.normal);     scrollview.add(button); } scrollview.contentsize = new cgsize(uiscreen.mainscreen.bounds.width, 50 * 40); add(scrollview); 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -