zoukankan      html  css  js  c++  java
  • ios 做瀑布流效果大致思路

          网上下载了一个ios做瀑布流图片展示源码,之前借助做web的经验,我已为ios类似于css style中有个float:left的效果,然后形成瀑布流效果,或者像用html中做个表格分成一行几列,然后在里面填充内容。


          刚下载瀑布流demo大致意路是这样:

         1. 总先做成几列是事先要清楚,有多少条记录,这个可以从json或者xml中读取后知道(json或xml最好将图片的高度和宽度也显示出来,便于后面用到)。

         2. 假设要做成3列,就用三个uitableview,宽度平均,高度动态,页面高度取uitableview中最高的。

         3. 三个uitableview初始化的时候用到tag(我越来越觉得tag在ios中的用处很大,就像js中读取html控件中的id一样),然后showsVerticalScrollIndicator和scrollEnabled设为no,separatorStyle设为UITableViewCellSeparatorStyleNone,添加到UIview中

        4.

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
         return 当行记录数/列;
    }
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        int  arrIndex=  当前indexPath.row * 列(3)+当前indexPath.column;|
       return [[XML/JSON objectAtIndex:arrIndex] objectForKey:@"高度"];
    }
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
       //从数据源中得到当前数组对应的数据,然后再用uitableviewcell填充

    感谢源码作者下载地址:http://code4app.com/codesample/4fdfecd96803fa117f000000

  • 相关阅读:
    Autofac ASP.NET Web API (Beta) Integration
    An Autofac Lifetime Primer
    Web api help page error CS0012: Type "System.Collections.Generic.Dictionary'2错误
    c++ 全局变量初始化的一点总结
    C++中extern关键字用法小结
    为什么多线程读写 shared_ptr 要加锁?
    CentOS7 安装Chrome
    在CentOS 7中使用VS Code编译调试C++项目
    am335x hid-multitouch.c
    implicit declaration of function 'copy_from_user'
  • 原文地址:https://www.cnblogs.com/hubj/p/2569471.html
Copyright © 2011-2022 走看看