设为首页 加入收藏

TOP

iOS中自定义Table View Cell
2014-11-24 07:43:28 来源: 作者: 【 】 浏览:0
Tags:iOS 定义 Table View Cell

跟着书上的范例做完了一般的table view,然后做做自定义表格,也遇到一些问题,最后终于解决了,记录下怎么弄出来的吧。


知识点:


1.自定义表格cell的格式。


2.自定义表格cell的view类。


3.使用自定义的view来呈现数据。


一、自定义表格cell的格式


新建xib文件,拖table view cell,label,image 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


@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


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android内置倒计时类CountDownTim.. 下一篇Android 监听来去电 弹出悬浮窗提..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·PostgreSQL 索引 - (2025-12-25 22:20:43)
·MySQL Node.js 连接 (2025-12-25 22:20:41)
·SQL 撤销索引、表以 (2025-12-25 22:20:38)
·Linux系统简介 (2025-12-25 21:55:25)
·Linux安装MySQL过程 (2025-12-25 21:55:22)