你好,游客 登录 注册 搜索
背景:
阅读新闻

iOS中自定义Table View Cell

[日期:2013-04-12] 来源:Linux社区  作者:ab_ba [字体:大 中 小]

跟着书上的范例做完了一般的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

linux
相关资讯       iOS自定义View  iOS自定义Cell 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款