iOS primary knowledge uitableview and simple usage

Source: Internet
Author: User

////VIEWCONTROLLER.M//zqrtableviewtest////Created by Zzqqrr on 17/8/24.//Copyright (c) 2017 zzqqrr. All rights reserved.//#import "ViewController.h"@interfaceViewcontroller () <UITableViewDataSource>@property (weak,nonatomic) iboutlet UITableView*TableView;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; Self.tableView.dataSource=Self ;}/** Set up group*/-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return 3;}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{if(section==0)//First Group {     return 1; } Else if(section==1)//Second group {     return 2; } Else {//Third Group     return 3; }}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{UITableViewCell*cell=[[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault Reuseidentifier:nil]; if(indexpath.section==0) {Cell.textLabel.text=@"First group first row"; }Else if(indexpath.section==1)    {        if(indexpath.row==0) {Cell.textLabel.text=@"first row of the second group"; }Else if(indexpath.row==1) {Cell.textLabel.text=@"Second group second row"; }    }    Else{        if(indexpath.row==0) {Cell.textLabel.text=@"The first line of the third group"; }Else if(indexpath.row==1) {Cell.textLabel.text=@"Third group, second row"; }Else{Cell.textLabel.text=@"Third group, third row"; }        }        returncell;}@end

iOS primary knowledge uitableview and simple usage

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.