ios - scrollView in Swift provides error in content size -


in storyboard ctrl-dragged uiscrollview in vc , connected property in code.

now i'm creating list of buttons inside scrollview list

  • button 1
  • button 2
  • ...

so exceed size of view. while creating via code buttons i'm storing them inside nsmutablearray , use code manage content size of scrollview

self.scrollview.contentsize = cgsize(width:self.view.bounds.size.width, height: self.arrayofcreatedbuttons!.lastobject!.frame.origin.y + self.arrayofcreatedbuttons!.lastobject!.frame.height) 

the problem scrollview does not scroll till last button created stops before.

what's error in code? in advance

edit

this code i'm using create buttons

            let btn = uibutton.buttonwithtype(uibuttontype.custom) uibutton             btn.frame = frame!              // frame! cgrect variable create list of buttons --> y cgfloat decreased every cycle              btn.layer.cornerradius = 0.5 * btn.bounds.size.width             btn.layer.maskstobounds = true              if (self.arrayofcreatedbuttons == nil) {                 self.arrayofcreatedbuttons = nsmutablearray()             }             self.arrayofcreatedbuttons?.addobject(btn)              // add btn scrollview             self.scrollview.addsubview(btn) 

i'm using in viewdidappear inside for cycle create multiple buttons.

and i'm setting content size after buttons created.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -