iOS --自定义xib

来源:互联网 发布:微信域名要备案吗 编辑:程序博客网 时间:2024/06/13 09:27

cell.h


#import <UIKit/UIKit.h>


@interface OtherCell :UITableViewCell

@property (weak, nonatomic) IBOutletUILabel *lable1;  //左边的lable 

@property (weak, nonatomic) IBOutletUILabel *lable2;  //右边的lable

// 返回xib界面中cell的高度

+ (CGFloat)cellHeight;


// 返回xib界面上写的重用cellID

+ (NSString *)cellID;


// xib中加载实例化一个Cell对象

+ (OtherCell *)otherCell;




@end



cell.m


#import "OtherCell.h"


@implementation OtherCell


- (void)awakeFromNib {

    // Initialization code

}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selectedanimated:animated];


    // Configure the view for the selected state

}



// 返回xib界面中cell的高度

+ (CGFloat)cellHeight

{

    // 查看一下xibcell的高度

    return 44;

}



// 返回xib界面上写的重用cellID

+ (NSString *)cellID{

    

    return@"OtherCell";

    

}


// xib中加载实例化一个Cell对象


+ (OtherCell *)otherCell

{

    // mainBundel加载xib,扩展名不用写.xib

    NSArray *arrayXibObjects = [[NSBundlemainBundle] loadNibNamed:@"OtherCell"owner:nil options:nil];

    return arrayXibObjects[0];

}


@end


0 0
原创粉丝点击