布局 - ios中这样的效果应该用UIScrollView还是用什么?
巴扎黑
巴扎黑 2017-04-17 17:43:23
0
6
352

在IOS中像这样的布局,好多APP都有这种效果,但不是UIWebView.

首先,能上下滚动,例如图中最后的图片是没有显示完的.还以继续向上滑动,我也不确定后面还有多少文本和图片
效果嘛,就像segmentfaultIOS客户端的文章详情页.就是图文混排,知乎的帖子页面.也是像这种,有文字有图,但是却不是WebView.请问这种效果是UIScrollView做出来的吗?是否有Demo?或者已经有轮子了?求解!

巴扎黑
巴扎黑

reply all (6)
黄舟

It can scroll up and down. The bottom layer must be based on UIScrollView. However, the implementation of the mixed graphics and text components requires related encapsulation by itself.

For example: FTCoreText

    阿神

    tableView nested tableView

      巴扎黑

      I feel like you are thinking too complicated. Break down the problem and think about it.

      First of all, scrolling up and down is the effect of the whole screen View,
      Then, the mixed arrangement of pictures and text is the effect of the content.

      Similar to the effect you mentioned, uitableView is generally used to do this, and the content is displayed in the tableviewcell. Whether the content is text, pictures, or both, that is the result of customizing the tableviewcell.

      Don’t be intimidated by the same responsible page. Compare the effect you see with the basic view provided by the system, analyze and decompose the functions, and you will roughly know how to implement it.

        阿神

        I see that there are quite a lot of answers. In order to avoid confusion, let me explain:
        UIScrollView, UITableView, and UICollectionView are all acceptable! And the effect achieved can be exactly the same!

        UIScrollView

        UIScrollView is the parent class of the latter two. It only implements the scrolling effect. You need to calculate the position of the View yourself according to your needs.

        UITableView

        And UITableView implements a very convenient API to implement list scrolling layout, which can meet your needs.

        UICollectionView

        UICollectionView is a more abstract encapsulation that can easily implement multi-element layout, including your needs.

        It is recommended that you have a deeper understanding of UITableView and UICollectionView, both of which are very commonly used components!

          巴扎黑

          Using UIScrollView is more troublesome because you have to manually calculate the coordinates of each view; using UITableView is more convenient as you only need to give the height of each view according to indexPath.row; UICollectionView is troublesome and I generally don’t use it much...

            黄舟

            The simplest and most practical implementation is to use UITableView; UIScrollView can also be implemented, and you need to calculate the position yourself (if you find it simple, you can also use UIScrollView); UICollectionView is still not useful for such an interface, and its usage scenarios need to be analyzed in detail.

              Latest Downloads
              More>
              Web Effects
              Website Source Code
              Website Materials
              Front End Template
              About us Disclaimer Sitemap
              php.cn:Public welfare online PHP training,Help PHP learners grow quickly!