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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -