ios - Change UIScrollView Content size -


i have viewcontroller uiscrollview, uiimages , uibuttons. in storyboard set size of uiscrollview to: width: 320, height: 570

i want change contentsize of uiscrollview when viewcontroller loaded.

i added side in viewdidload:

        scrlmain.contentsize = cgsize(width: 320,height: 790) 

and added code in viewdidlayoutsubviews:

        self.scrlmain.translatesautoresizingmaskintoconstraints = true 

but uiscrollview still last size = 570. can't use viewdidappear because, when press button, need change color. when has changed color, uiscrollview moves up.

what did wrong?

all code:

    override func viewdidload() {     super.viewdidload()     scrlmain.delegate = self     scrlmain.contentsize = cgsizemake(320, 790)     } override func viewdidlayoutsubviews() {     self.scrlmain.translatesautoresizingmaskintoconstraints = true     self.scrlmain.contentsize = cgsize(width: self.scrlmain.frame.width, height: 60.0 + 5 * (self.scrlmain.frame.width / 16.0 * 5.0)); } 

there error in function:

override func viewdidlayoutsubviews() { self.scrlmain.translatesautoresizingmaskintoconstraints = true self.scrlmain.contentsize = cgsize(width: self.scrlmain.frame.width, height: 60.0 + 5 * (self.scrlmain.frame.width / 16.0 * 5.0)); } 

i delete code:

self.scrlmain.contentsize = cgsize(width: self.scrlmain.frame.width, height: 60.0 + 5 * (self.scrlmain.frame.width / 16.0 * 5.0)); 

and right


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -