Looking for a UI library to present Data horizontaly in iOS

后端 未结 1 659
清酒与你
清酒与你 2021-01-16 07:50

Does anyone know of a UI Library for iOS, that acts like a horizontal UITabelView?

I want to scroll cells from right to left and not from up to down.

1条回答
  •  借酒劲吻你
    2021-01-16 08:44

    I had a similar requirement: Horizontally scrolling tables in cells of a normal, vertically scrolling table.

    My solution: I put a standard UIiew in the outer table's cell. This view had its transform property set to turn by 90°, serving as a "hinge", turning its contents to the side.

    In the hinge view was another UITableView. Since it is contained in the turned view, it appears horizontally on the screen. The cells of this inner table contained another hinge view, turning their contents -90°, back to the upright orientation.

    This might sound a little confusing, but it gives you all advantages of table views, in horizontal orientation. It's less confusing if you leave out the outer table view with their cells which are not needed in your case.

    Edit: to answer comment

    Performance was definitely great. Actually, performance was the major reason to switch to this approach. Table views are especially great for displaying huge data sets, since they only instantiate visible views (cells) and reuse them after being scrolled out. By itself a table view is quite light weight and very optimized for its purpose. My data sets where middle size, I'd say (about 100 items in both dimensions) and scrolling was perfectly smooth.

    The other thing besides performance I was concerned about was touch handling. It went out that the table views (which derive from scroll views) always detected the gesture correctly (scrolling a scroll view in a scroll view is not easy to get right). If you swiped vertically the outer table view would handle the events, if you swiped horizontally the inner table gets all the events. I was quite impressed of how well the framework handled this non standard situation.

    0 讨论(0)
提交回复
热议问题