ios - How to set UIScrollView height correctly -


i having issues getting uiscrollview scroll way expect to. 1,200 points high, , have managed scroll height, having couple of problems.

first of all, content starting further down screen should be. looks scrolled down 64 pixels below navigation bar (the height of navigation bar). how can starts right below navigation bar?

also, have 3 buttons in view not calling functions when tapped. assume because have made mistake size of uiscrollview somehow. buttons work if move them inside main frame (the size of screen).

this code:

override func viewdidload() {     super.viewdidload()      scrollview.contentsize = cgsize(width: view.bounds.width, height: 1200) }  override func viewdidlayoutsubviews() {     super.viewdidlayoutsubviews()     scrollview.frame = cgrect(x: 0, y: 0, width: view.bounds.width, height: view.frame.height) } 

update:

i fixed issue buttons. forgot set height of view objects placed on within uiscrollview. still haven't fixed issue starting point though, if has ideas?

if put breakpoints in code, notice viewdidlayoutsubviews get's called after viewdidload. effectively, when setting scrollview.contentsize in viewdidload, views frame not loaded, , because of cgsize(width: view.bounds.width, height: 1200) potentially set content size {0, 1200}.

you want move contentsize code after update scrollview frame, inside viewdidlayoutsubviews method.

regarding first part of question, might want take @ uiscrollview's contentinset property.

hope helps!


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -