i want to add buttons dynamically along with the scrollview ,suppose there are like 100 buttons to be added on scrollview it would be humongous to add it on nib file ,so i want to know how to write the code , add buttons dynamically on top of image view on scrollview
i want to add buttons dynamically along with the scrollview ,suppose there are like
Share
What you need to do is create a loop, create
UIButtons. Setup buttons & add them as subviews toUIScrollView. Code follows.What i am basically doing here is having variables for X & Y co-ordinates. As I am looping through to create
UIButtonsam creating the appropriateCGRectstruct to decide where to place the button in theUIScrollView. After adding that button to scrollView, change the X & Y values to where ever you want to place the next button.At the end dont forget to set the
ContentSizefor scrollview so that it enables scrolling.PS: All this code is typed free hand, might have small syntactical errors but the logic is solid.