I have a fairly simple app with a few UIViewControllers some of which have UITableViews added.
(Note: I am not using UITableViewControllers!)
My goal is to keep the selected row highlighted (selected) when scrolling the table and when moving to a different view then back.
Example 1:
View A with Table A - select row 3
Scroll the table up/down - row 3 should remain selected.
Example 2:
View A with Table A - select row 2
Segue to View B with Table B, select nothing, segue back to View A.
Row two should (still) be selected.
The way it is now, the selected row becomes deselected when I scroll or move to another view controller (and back).
Any ideas why I can't retain the selected row ?
EDIT:
I found that the issue is this line of code:
tableView.selectRow(at: selectedIndexPath, animated: false, scrollPosition: .middle)
However if I change ".middle" to ".none" it works as expected:
tableView.selectRow(at: selectedIndexPath, animated: false, scrollPosition: .none)
Of course now I can't bring the selected row into view.
Any ideas on why this happens or how to resolve it?
Related
So I have a UIViewController, which has a Navigation Controller embedded in it, and it also has a table view with several populated cells. If I tap on a cell it brings me to another page, and then when I go back to the table view page, the navigation bar no longer works. I'm unsure as to what is causing this to happen.
This is how I navigate to the new page after a table view cell has selected.
let itemPage = ItemPageViewController()
navigationController?.pushViewController(itemPage, animated: true)
I want to show a ViewController where it has two UIViews, just like finder in Mac.
The left view contains a tableview with items.When user selects an item the right view displays tableView with related data.
So the next requirement is that which ever tableView is shown on the right side is editable for selection of sub items in rows and once the editing is done it should keep its state, so that on selecting the second item and re-selecting the first item, the tableView should show all the selected sub items.
You can refer - https://www.raywenderlich.com/94443/uisplitviewcontroller-tutorial-getting-started
That is called splitviewcontroller or master detail controller
I little confused with configuring detailed view with MMDrawerController and without navigation controller.
I have TableView with custom cells inside ViewController. When users presses cell i want to show another ViewController with details about selected item. For this case i use didSelectRowAtIndexPath method from my tableview.
There are many cells in my table, that is why when user presses "back" button on detailed view i want to navigate to selected cell not to the top of table. What types of segues i should use?
I have a view which is used for updating the content of a table cell and adding new cells to a table.
Updating the content of a table cell can be achieved by touching a cell. In this case the view will be instantiated programmatically and the data of the cell will be sent to the view. Adding new cells to the table can be achieved by clicking on a button which will show the view as a segue without data.
The navigation bar of the view contains a save button which will update the data of the cell or add a new cell.
I thought about setting a boolean value in the view to detect if the purpose is updating or adding a cell but I don’t think that this would be the right way. What is the best solution for this problem?
I have a UITableview, which has a list of cars. On selecting any row, a UIViewcontroller is to be shown, showing the details of the car selected.
However, prepareForSegue: is not getting called when I tap on any row in the Search Table View Controller.
After searching on the internet, I looked at a few examples and I tried to follow them to do this job, using [self performSegueWithIdentifier:#"ShowProductDetail" sender:nil];
in my didSelectRowAtIndexPath: method. It performed the job, but now I don't see a BACK button. I need the BACK button in the navigation bar in the new view controller, which is the selected one in the image:
I was just missing my cellIdentifier for the prototype cell.