开发者

how to implement swipe in table view iphone

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 load开发者_Go百科ed. How to implement this? Thanks in advance


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).


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜