我有一個2行的表,每列3列,一個數組有5個值。這些值應該連續顯示在3列中,例如用3列填充錶行
indexPath.row 0: Array[0] | Array[1] | Array[2]
indexPath.row 1: Array[3] | Array[4] |
我想創造一些編碼,這使我的價值觀(它並不關心有多少如5,6,7,...,20,21在3列的行中的格式)行數與數組的大小一起計算。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSMutableArray *values = [... getValues];
int no=0;
if (values) {
no=(values.count+1)/3;
}
else{
no=0;
}
return no;
}
我目前的問題是,我沒有得到分佈在列中的5個值。 我與計算struggeling左右,這些不適合與數組的索引...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//order values in 3 columns and 2 rows (currently)...
}
BR, mybecks