iOS Learning Note (iii) TABLEVIEW

Source: Internet
Author: User

If you need to keep track of what is in Nsarray, you need to override the Descriptionwithlocal method. First create a new category for Nsarray, add the following code to the newly created. m file

-(NSString *) Descriptionwithlocal: (ID) Local

{

nsmutablestring *string = [nsmutablestring string];

[String appendstring:@ "("];

for (id obj in self) {

[String appendformat:@ "\n\t\"%@\ ",", obj];

}

[String appendstring:@ "\ n)"];

return string;

}

As a result, the data in the Nsarry is no longer utf-8 encoded in NSLog and is displayed as the original data.

UITableView

Need a data source to display the data


1. Need to join the data source protocol Uitableviewdatasource; <

2. Set the table group number-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView; <

3. Set the number of rows in each group-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (Nsinteger) Sectio    n; <

4. Set the data content displayed in each group-(UITableViewCell *) TableView: (UITableView *) Tableviewcellforrowatindexpaht: (Nsindexpath * ) Indexpath {

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

Indexpath.section is the group name

The cell is the data in the returned group.

5. Set the title of the group-(NSString *) TableView: (UITableView *) TableView titleforheaderinsection: (Nsintger) Secton; <

6. Set the title of the footer, sub-headings at the bottom of the group-(NSString *) TableView: (UITableView *) TableView titleforfooterinsection: (nsinteger) Section    ; <

7. The dictionary returns all keys methods Nsarray *items = [Self.cities AllKeys]; < The order of the data out is messy.

8. Separate the groupings in the UITableView (that is, set the style, but the style can only be set at initialization time)

UITableView *tableview = [[UITableView alloc] Initwithframe:style: (Uitableviewstyle)]; <

9. Proxy method:-(void) TableView: (UITableView *) Tableviewdidselectrowatindexpath: (Nsindex *) indexpaht; <

Details determine success or failure!

iOS Learning Note (iii) TABLEVIEW

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.