views:

165

answers:

2

i have a table view. i divided it into 3 sections. i want to implement swipe in this tableview. when i swipe in table view, next view will be loaded. How to implement this? Thanks in advance

A: 

Generally, your table view controller will implement the UITableViewDelegate protocol. The tableView:didSelectRowAtIndexPath: method is called when the user touches one of the rows in your table view. If you implement the method, you can use row and section properties of the NSIndexPath that are passed in to determine which row in you table the user selected. Based on the selection, you can then create or initialize the appropriate next view controller that you want to load and then push the new controller on the table view controller's navigationController.

For further info, try reading:

  1. UITableViewController Class Reference
  2. Table View Programming Guide for iOS
  3. UITableViewDelegate Protocol Reference
Jason Jenkins
It is the standard select method you're describing here. The guy is asking about swiping.
rebellion
Yes, but he also said that he wants to "load the next view" and swiping would be a very non-standard gesture for disclosing a follow-on view. I was assuming that possibly he was very inexperienced or that perhaps English is not his native language and suggested the simplest approach.
Jason Jenkins
+1  A: 

You have basically two options:

I: Use UISwipeGestureRecognizer

Since I never worked used it, there is not much I can tell you about this way. Just see the official documentation for further information. You should know, that it was introduced with iOS 3.2, so there is no support for iPhones which are not running iOS 4.0, so especially firstGen iPhones will be excluded.

II: Overwrite touchesBegan/Moved/Ended

Read this post for further information, this should be exactly what you need. Of course, this solution does not only work for UITableViews but for every class that inherits from UIResponder (and consequently for every UIView).

Phlibbo