#import <UIKit/UIKit.h>
@interfaceMyCell:UITableViewCell@endm文件#import "MyCell.h"
@implementationMyCell-(id)initWithStyle:(UITableViewCellStyle)stylereuseIdentifier:(NSString*)reuseIdentifier{self=[superinitWithStyle:stylereuseIdentifier:reuseIdentifier];if(self){UILabel*tempLabel=[[UILabelalloc]initWithFrame:CGRectMake(10,10,150,25)];[tempLabelsetText:@"Test my Label"];[selfaddSubview:tempLabel];[tempLabelrelease];}returnself;}-(void)setSelected:(BOOL)selectedanimated:(BOOL)animated{[supersetSelected:selectedanimated:animated];// Configure the view for the selected state}@end
在你的 tableView 初始化 cell 的时候
#pragma mark -
#pragma mark Table View Data Source Methods
-(NSInteger)tableView:(UITableView*)tableViewnumberOfRowsInSection:(NSInteger)section{return[noteListArraycount];}-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{UITableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:@"thecell"];if(cell==nil){cell=[[MyCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:@"thecell"];}returncell;}