iOS Navigate TableView with Arrow Keys

918 views Asked by At

How can a UITableView be navigated with arrow keys (physical keyboard) much like the spotlight behavior that was introduced in iOS 10?

Looking to have a user type into a search box and use the up/down arrow to highlight a row in a tableview and press return key to select the row.

I have not found any resources on the topic.

Please provide sample code in Swift.

1

There are 1 answers

0
Luzo On

Did not try it, but this could be the answer for you.

  self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Top, animated: true)

and use the text field delegate to handle return.

Edit: For highlighting use

tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!

and update your cell visual