iOS Seventh day (basic usage of 1:uitableview)

Source: Internet
Author: User

Table control

#import "HMViewController.h"@interfaceHmviewcontroller () <UITableViewDataSource>@property (Weak, nonatomic) Iboutlet UITableView*TableView;@end@implementationHmviewcontroller#pragmaMark-Data Source methods//if not implemented, the default is 1-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return 2;}//The total number of data in each grouping//sction: Number of groupings-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{if(Section = =0) {        //No. 0 Group        return 5; } Else {        return  -; }}//tells the table control the details of cell cells in each row//Indexpath//@property (nonatomic,readonly) Nsinteger section; Grouping//@property (nonatomic,readonly) Nsinteger row; Line-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{//when instantiating Tableviewcell, use the Initwithstyle method to instantiateUITableViewCell *cell =[[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault Reuseidentifier:nil]; Cell.textLabel.text= [NSString stringWithFormat:@"Dark Horse student%02d period-%04d", Indexpath.section, Indexpath.row]; returncell;}//returns the grouped caption text-(NSString *) TableView: (UITableView *) TableView titleforheaderinsection: (nsinteger) section{return[NSString stringWithFormat:@"Dark Horse%02d period", section];}-(NSString *) TableView: (UITableView *) TableView titleforfooterinsection: (nsinteger) section{if(Section = =0) {        return @"It's too bull."; } Else {        return @"A bull's fork is shining brightly"; }}@end

iOS Seventh day (basic usage of 1:uitableview)

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.