(1)派生类:@interface TimeZoneViewController : UITableViewController
(2)增加以下方法:
//告诉 tableView有几个分段
-(NSInteger) numberOfSectionInTableView:(UITableView*)tableView{
return 1;
}
//告诉TABLEVIEW每个分段有几行
-(NSInteger) tableView:(UITableView*) tableView numberOfRowsInSection:(NSInteger)section
{
return [names count];
}
//告诉程序每行记录的显示方法,返回的UITableViewCell描述了当前行的显示内容
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *Myidentifer=@"Myidentifer";
UITableViewCell* cell=[tableView dequeueReusableCellWithIdentifier:Myidentifer];
if(cell==nil){
cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Myidentifer] autorelease];
}
NSString* name=[names objectAtIndex:indexPath.row];
cell.textLabel.text=name;
return cell;
}
(3)其中names是一个 NSMutableArray * names; 在初始化动作里,可以对其进行赋值