Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to center uitableview selection with indexpath value

I am saving the indexPath selection from a subview and passing it to the parent view with delegates. When I got back to my subview from my main view I pass the indexPath back to it and show the user which cell they previously selected with a tick in the accessory view of the tableviewcell.

One problem being if the user has selected a cell out of a fairly big list its hard to find the cell they selected again incase they wanted to change it (being that they made a mistake)

I would like to know if their is a way to use indexPath or something similar to center the previously selected cell of the uitableview to the center of the screen?

UPDATE::

Here is a graphical view of what I am trying to achive to make it abit more understandable..

step one : select cell then go to subview and select the cell (value) you want to pass back to main view (save indexPath of selected cell) enter image description here

step two: user either wants to change his selection or made a mistake and was ment to select the cell below the one they chose... repeat previous steps but display previously selected cell in the center of the view..

enter image description here

like image 556
C.Johns Avatar asked Oct 06 '11 20:10

C.Johns


People also ask

What is indexPath UITableView?

IndexPath contains information about which row in which section the function is asking about. Base on this numbers you are configuring the cell to display the data for given row.

How do I find the indexPath of a cell?

You can walk up the view hierarchy to find the containing table view cell and the containing table view. Then you can ask the table view for the cell's index path.

Is it possible to add UITableView within a UITableViewCell?

yes it is possible, I added the UITableVIew within the UITableView cell .. :) no need to add tableview cell in xib file - just subclass the UITableviewCell and use the code below, a cell will be created programatically.

What is indexPath in TableView Swift?

indexPath(for:)Returns an index path that represents the row and section of a specified table-view cell.


1 Answers

Have you tried the following function

[tableView scrollToRowAtIndexPath: atScrollPosition:UITableViewScrollPositionMiddle animated:YES]
like image 149
BumbleBoks Avatar answered Sep 26 '22 17:09

BumbleBoks