I have created a view controller which includes a scrollview and on scrollview i am adding 5 different custom UIView horizontally and i want that custom UIView should be added randomly depending on custom UIViews width and accordingly contentSize of scrollView should be set.
Please help me to solve this problem.
Finally i came up with solution
Just put your five view in a mutable array, and initialize your x offset to 0. Then get a random number and grab the view in the array (random modulo array count, to stay inside the array). Add this view to your scrollview and increase your x offset by the width of the choosed view. Stop when array count is zero for example. Then your x tells you the width of your scrollview, simply set its contentSize :