Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
118 views
in Technique[技术] by (71.8m points)

ios - UITableView move to cell

I want to make next:

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.

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).

What is a right wait to make transition from 1 to 10 cell.

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.

In other words I need to make scrollToRowAtIndexPath

Thanks!

question from:https://stackoverflow.com/questions/10269587/uitableview-move-to-cell

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...