UITableView移动到单元格 [英] UITableView move to cell
问题描述
我想下一步:
我有一个UITableView,必须显示单词(AZ)。
I have an UITableView that have to dispaly words (A-Z).
目前,当视图加载时,我有一个显示的单元格(这是正确的)。第一个单元格显示我的数组单词中的第一个单词。
Currently when view did load I have one cell that displayed (and this is correct). First cell display first word from my array words.
目的:
我想移动到必须从我的数组中显示10个单词的单元格,但问题是indexPath.row = 10的单元格不存在(这是正确的,因为我还没有滚动)。
Purpose: I want to move to the cell that must display 10 word from my array, but problem is that the cell with indexPath.row = 10 does not exist (and this correct, because I don't scroll yet).
什么是正确的等待从1到10个单元格。
What is a right wait to make transition from 1 to 10 cell.
我想如果我不使用 dequeueReusableCellWithIdentifier
来创建我的单元格我可以做到并解决我的问题,但我的意思是设备内存的这个问题。
I think if I don't use dequeueReusableCellWithIdentifier
for creating my cell I can do it and solve my problem, but I mean this problem for device memory.
换句话说,我需要做 scrollToRowAtIndexPath
谢谢!
推荐答案
你是正确的<$> c $ c> scrollToRowAtIndexPath 方法。因此,您需要做的就是创建一个新的IndexPath,其中包含您要移动到的行,例如,行索引= 10:
You are right to identify the scrollToRowAtIndexPath
method. So all you need to do is create a fresh IndexPath with the row you wish to move to, e.g., row index = 10:
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:10 inSection:indexPath.section]
atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
这篇关于UITableView移动到单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!