int column = 3;//列数 NSInteger count = self.dataArray.count;//数据个数 for (int i = 0; i < count; i++) { int columnIndex = i % column; // 列索引 int rowIndex = i / column; //行索引 //... }
九宫格布局获取行/列索引
原文:http://www.cnblogs.com/codelu/p/5188245.html