1, Case description: The simplest table view, 01
Figure 01
2, Team.plist
<?xml version="1.0"encoding="UTF-8"? ><! DOCTYPE plist Public"-//apple//dtd PLIST 1.0//en" "HTTP://WWW.APPLE.COM/DTDS/PROPERTYLIST-1.0.DTD"><plist version="1.0"> <array> <dict> <key>name</key> <string>a1-South Africa </string> <key>image</key> <string>southafrica</string> </dict> <dict> <key>name</key> <string>a2-Mexico </string> <key>image</key> <string>mexico</string> </dict> <dict> <key>name</key> <string>b1-Argentine </string> <key>image</key> <string>argentina</string> </dict> <dict> <key>name</key> <string>b2-Nigerian </string> <key>image</key> <string>nigeria</string> </dict> <dict> <key>name</key> <string>c1-England </string> <key>image</key> <string>england</string> </dict> <dict> <key>name</key> <string>c2-American </string> <key>image</key> <string>usa</string> </dict> <dict> <key>name</key> <string>d1-Germany </string> <key>image</key> <string>germany</string> </dict> <dict> <key>name</key> <string>d2-Australia </string> <key>image</key> <string>australia</string> </dict> <dict> <key>name</key> <string>e1-Holland </string> <key>image</key> <string>holland</string> </dict> <dict> <key>name</key> <string>e2-Danish </string> <key>image</key> <string>denmark</string> </dict> <dict> <key>name</key> <string>g1-Brazil </string> <key>image</key> <string>brazil</string> </dict> <dict> <key>name</key> <string>g2-Korea </string> <key>image</key> <string>northkorea</string> </dict> <dict> <key>name</key> <string>h1-Spain </string> <key>image</key> <string>spain</string> </dict> <dict> <key>name</key> <string>h2-Swiss </string> <key>image</key> <string>switzerland</string> </dict> </array></plist>
3. Pictures
Algeria.png, Argentina.png, Australia.png, Brazil.png, Cameroon.png,
Chile.png, Cotedivoire.png, Denmark.png, England.png, France.png,
Germany.png, Ghana.png, Greece.png, Holland.png, Honduras.png,
Italy.png, Japan.png, Mexico.png, Newzealand.png, Nigeria.png,
Northkorea.png, Paraguay.png, Portugal.png, Serbia.png, Slovakia.png,
Slovenia.png, Southafrica.png, Southkorea.png, Spain.png, Switzerland.png,
Uruguay.png, Usa.png
4, main.storyboard,02
Figure 02
5,. h
#import <UIKit/UIKit.h>@interface*listteams; @end
6,. m
#import "CQ21ViewController.h"@interfaceCq21viewcontroller ()@end@implementationCq21viewcontroller- (void) viewdidload{[Super Viewdidload]; //Load Team DataNSBundle *bundle =[NSBundle Mainbundle]; NSString*plistpath = [Bundle Pathforresource:@"Team"OfType:@"plist"]; Self.listteams=[[Nsarray alloc] initwithcontentsoffile:plistpath];}- (void) didreceivememorywarning{[Super didreceivememorywarning];}#pragmaMark Uitableviewdatasource Agreement-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{//returns the number of rows in a table returnSelf.listTeams.count;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{//1. Load cell StaticNSString *cellidentifier =@"Cellidentifier"; UITableViewCell*cell =[TableView Dequeuereusablecellwithidentifier:cellidentifier]; if(Cell = =Nil) {Cell=[[UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } //2, set the cell TextlabelNsuinteger row =[Indexpath Row]; Nsdictionary*rowdict =[Self.listteams Objectatindex:row]; Cell.textLabel.text= [Rowdict Objectforkey:@"name"]; //3. Set up a picture of the cellNSString *imagepath = [rowdict objectforkey:@"Image"]; ImagePath= [ImagePath stringbyappendingstring:@". PNG"]; Cell.imageView.image=[UIImage Imagenamed:imagepath]; //4. Set cell expansion view as extension indicatorCell.accessorytype =Uitableviewcellaccessorydisclosureindicator; returncell;}@end