ios - Scroll Vertically in a UIScrollView with Vertical Paging enabled -



ios - Scroll Vertically in a UIScrollView with Vertical Paging enabled -

hoping give me direction here. have scrollview setup vertically paging. problem views larger screen (vertically). desired effect have view scroll bottom , page next page. image below trying depict.

i have tried setting size of scrollview , content size size of view offset views correctly. can't scroll see bottom of view, pages next view.

thanks advice.

class viewcontroller: uiviewcontroller { allow scrollview = uiscrollview() // create scrollview override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. //set , add together scrollview view scrollview.frame = self.view.frame self.scrollview.pagingenabled = true self.view.addsubview(scrollview) //an array of uicolors add together views allow x : [uicolor] = [uicolor.bluecolor(),uicolor.redcolor(),uicolor.yellowcolor()] //for each uicolor add together view 100px larger height of scrollview index in 0...x.count-1{ // allow subview = uiview(frame: cgrectmake( 0, //x offset (self.scrollview.frame.height + 100) * cgfloat(index), //y offset self.scrollview.frame.width, // width (self.scrollview.frame.height + 100))) // height subview.backgroundcolor = x[index] //background color scrollview.addsubview(subview) // add together view } // allow c = (self.scrollview.frame.size.height + 100) * cgfloat(x.count) self.scrollview.contentsize = cgsizemake(self.scrollview.frame.width, c) //background color self.view.backgroundcolor = uicolor.greencolor() } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } }

user4's answer, in objective-c:

uiscrollview *scrollview = [[uiscrollview alloc] init]; scrollview.frame = self.view.frame; scrollview.pagingenabled = yes; scrollview.backgroundcolor = [uicolor yellowcolor]; [self.view addsubview:scrollview]; scrollview.delegate = self; nsarray *x = @[[uicolor bluecolor], [uicolor redcolor]]; (int = 0; < x.count; i++) { uiview *subview = [[uiview alloc] initwithframe: cgrectmake(0, (scrollview.frame.size.height) * i, scrollview.frame.size.width, scrollview.frame.size.height) ]; uiswitch *switchctrl = [[uiswitch alloc] initwithframe:cgrectmake(5, 5, 20, 20)]; subview.backgroundcolor = x[i]; [subview addsubview:switchctrl]; [scrollview addsubview:subview]; } float c = (scrollview.frame.size.height) * x.count; scrollview.contentsize = cgsizemake(scrollview.frame.size.width, c); self.view.backgroundcolor = [uicolor greencolor];

ios swift uiscrollview

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -