Code implementation UITableView Click cell jump

Source: Internet
Author: User

  1. First, set up the proxy and data source methods in Tableviewcontroller:

    @interface Firsttableviewcontroller ()<UITableViewDataSource,UITableViewDelegate>

  2.  implement a series of data source methods: Let them display data such as simply displaying a few lines:

    #pragma the mark data source method

    /**

    * How many sets of data are there?

    */

    -(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView

    {

    return 2;

    }

    /**

    * How many lines are there in section group

    */

    -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section

    {

    if (section = = 0) {

    return 2;

    }else{

    return 4;

    }

    }

    -(UITableViewCell *) TableView: (uitableview*) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath

    {

    UITableViewCell *cell = [[UITableViewCell alloc]initwithstyle:uitableviewcellstyledefault ReuseIdentifier:nil];   

    Cell.textLabel.text = @ "11";

    return cell;

    }

  3. Add this method to implement the jump.

    -(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath

    {

    Secondtableviewcontroller *svc = [[Secondtableviewcontroller alloc]init];

    [Self.navigationcontroller pushviewcontroller:svc Animated:yes];

    }

    Note: After clicking on the cell, create a uiview and then push it with Navigationcontroller.

    This will allow you to successfully create a new page by clicking on the cell and implementing the jump.

    ---------from Baidu experience, there are deletions, thanks to the original

Code implementation UITableView Click cell jump

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.