To show 25 images randomly out of 40 images in a grid view

前端 未结 4 1010
醉梦人生
醉梦人生 2021-01-24 15:45

I am creating an iphone app in which I need to create a grid view of 25 images. I am doing that by taking 25 images in an array, and displaying them by using for loop by changin

4条回答
  •  情深已故
    2021-01-24 16:20

    1. create a set
    2. create a random number between 0 and 40 and put it in set
    3. check set size
    4. if set size is less than 25, go to step 2
    5. convert set to array

    This is one way to do it and certainly there are better and faster ways, but if you want simplicity, use something like this or peoro's suggestion.

提交回复
热议问题