在单个tableview单元格中显示两个数组值 [英] Display two array values in single tableview cell

查看:80
本文介绍了在单个tableview单元格中显示两个数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在tableview中为每个单元格显示webservies数组值我需要显示两个值Ex:总共十个值表示每个单元格在每行中显示2个值。 webservies总值九表示每个显示两个值,最后一个单元格显示一个值。我怎样才能帮助我。新的开发。

I want to display webservies array values in tableview for each cell i need to display two values Ex:total ten values mean each cell display 2 values in each row. webservies total value nine means each display two values last cell display one value. how can i achieve this help me. new for development.

推荐答案

cellForRow:中你应该发送单元格数组中的值 [yourArray objectAtIndex:(indexPath.row * 2)] [yourArray objectAtIndex:(indexPath.row * 2 + 1 )] 。所以第6行将获得索引12和13的对象。
此外,您应该始终检查对象是否存在。类似于 - if(yourArray.count>(indexPath.row * 2)) if(yourArray.count>(indexPath.row *) 2 + 1))比发送到其他小区没有。 (当你得到奇数个值时,你会在单元格中得到一个对象。

In cellForRow: you should send the cell the values from the array at [yourArray objectAtIndex:(indexPath.row * 2)] and [yourArray objectAtIndex:(indexPath.row * 2 + 1)]. so row 6 will get the objects for indexes 12 and 13. Also you should always check if the objects exists. something like - if (yourArray.count > (indexPath.row * 2)) and if (yourArray.count > (indexPath.row * 2 + 1)) than send to cell else don't. (than you will get one object in cell when you get odd number of values.

这篇关于在单个tableview单元格中显示两个数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆