Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / iOS中自定义Table View Cell

跟着书上的范例做完了一般的table view,然后做做自定义表格,也遇到一些问题,最后终于解决了,记录下怎么弄出来的吧。知识点:1.自定义表格cell的格式。2.自定义表格cell的view类。3.使用自定义的view来呈现数据。一、自定义表格cell的格式新建xib文件,拖table view cell,label,image view到画板上,如图:二、自定义表格cell的view类新建objective-c class,继承UITableViewCell类,见代码://
//  SimpleTableViewCellController.h
//  SimpleTableStoryBoradTest
//
//  Created by wong linwei on 12-9-8.
//  Copyright (c) 2012年 P&T. All rights reserved.
//#import <UIKit/UIKit.h>@interface SimpleTableViewCell : UITableViewCell {
    UIImageView *cellImage;
    UILabel *cellName;
    UILabel *cellTime;
}@property (strong, nonatomic) IBOutlet UIImageView *cellImage;
@property (strong, nonatomic) IBOutlet UILabel *cellName;
@property (strong, nonatomic) IBOutlet UILabel *cellTime;@end //
//  SimpleTableViewCellController.m
//  SimpleTableStoryBoradTest
//
//  Created by wong linwei on 12-9-8.
//  Copyright (c) 2012年 P&T. All rights reserved.
//#import "SimpleTableViewCell.h"@implementation SimpleTableViewCell@synthesize cellImage;
@synthesize cellName;
@synthesize cellTime;- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];    // Configure the view for the selected state
}
@end