I have a navigation view controller that will show the table view of my application, but I can’t get it to move to a new view when I tap an entry in the table. How do I link a new view to an element in the parent view?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have a
navigation view controller?You either have a navigation controller or a view controller.
A navigation controller has a stack of view controllers and pushes and pops between them.
In regards to your question you need to define the tableview’s delegate as
self. If you’re subclassingUITableViewControllerthen you don’t have to worry about this.Then implement this method:
So in the code above we’re using the delegate method
didSelectRowAtIndexPathwhich gets called when the user “clicks” a table view cell.You can use the
indexPathobject to find out which row was tapped.int rowIndex = [indexPath row];will get you the row index of the cell that was tapped.