I have an array which loads in a database depending on what button the user chooses. How can I add these buttons to a scroll view which is only as large as it needs to be to hold all the buttons? I know I can declare the size of the scroll view, but I don’t want it to be too large so that it can fit a large number of buttons then have lots of empty space if a smaller array is used to create less buttons. Is there an easy way to do this?
Share
I assume you can figure out the vertical height required to display the number of buttons to be displayed before adding them to the scrollview.
If so, at the time of adding a fresh set of buttons, or ‘refreshing’ the scrollview, I guess you can simply set the correct
contentSizeof the scrollview.Check the UIScrollView reference for
@property(nonatomic) CGSize contentSize