写在前面
- 本文使用的IDE为Xcode9.4.1
- 目的是展示在控件TableView中自定义Cell
- 使用的语言为Objective-C
- 本例就创建一个现实团队成员基本信息的cell:要展示姓名、性别、ID号与头像。显然,系统提供的cell不能达成要求,所以需要自定义。
实现方法
1、构造一个自己需要的TableView中的Cell的样式,我们先新建Grouper.xib、Grouper.h、Grouper.m文件。
.h文件:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface GrouperCell : UITableViewCell//该类继承于UITableViewCell
@property (retain,nonatomic) IBOutlet UILabel * lbl_name;
@property (retain,nonatomic) IBOutlet UILabel * lbl_ID;
@property (retain,nonatomic) IBOutlet UILabel * lbl_gender;
@property (retain,nonatomic) IBOutlet UIImageView * lbl_headPortrait;
@end
.m文件:
#import "GrouperCell.h"
@implementation GrouperCell
@synthesize lbl_ID,lbl_name,lbl_gender;
-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

最低0.47元/天 解锁文章
7238

被折叠的 条评论
为什么被折叠?



