How to populate a UIScrollView with UIImageView's lines up in a row

筅森魡賤 提交于 2019-12-08 10:17:55

问题


I need some code on how to make a UIScrollView that contains UIImageViews lined up like the iPhone photo's app that comes with the phone.


回答1:


This is a frequently asked question around here. Several questions that might have answers on the various aspects of doing this are

  • UIScrollView image/photo viewer with paging enabled and zooming
  • Photos app-like gap between pages in UIScrollView with pagingEnabled
  • Flicking through pages / photos with UIImageViews (similar to Facebook photos app or home screen)
  • Is it Possible to Center Content in a UIScrollView Like Apple’s Photos App?
  • create multiple images view like the photo app iphone sdk

The Three20 framework has a drop-in component for doing just this, as well.




回答2:


Best way to do this is probably a standard UITableView whose cells contain a row of four UIImageViews. In -tableView:cellForRowAtIndexPath:, load the four images corresponding to that row (assuming you've got them in a linear array, the image indices would be (row*4), (row*4 + 1), (row*4 + 2), and (row*4 + 3)), and apply them to the cell's image views. Make sure to use -dequeueReusableCellWithIdentifier and initWithStyle:reuseIdentifier: or your performance—specifically, the overhead of creating and destroying all the views involved—will be terrible.



来源:https://stackoverflow.com/questions/1962658/how-to-populate-a-uiscrollview-with-uiimageviews-lines-up-in-a-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!