开发者

How to return cell number in cell label

I have a UITableViewCell, and in it i have two labels side by side. the one is editable. But the other one i want rep开发者_开发问答opulated with the actual row number of the cell...

Is this possible at all? where would i add the code to perform the calculation?


In the cellForRowAtIndex method set the label's text variable to the indexPath.row.

someLabel.text = [NSString stringWithFormat:@"%d", indexPath.row];

However, if you are using a UITableView subclass, make sure that you have made the NSObject subclass of it first with a property of someLabel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜