UITableView自定义Cell

来源:互联网 发布:程序员新人第一天 编辑:程序博客网 时间:2024/05/04 10:51
#pragma mark - TableView-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {    return [self.array count];}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    static NSString *CustomCellIdentifier = @"CustomCellIdentifier";    static BOOL nibsRegistered = NO;    if (!nibsRegistered) {        UINib *nib = [UINib nibWithNibName:@"ListTableViewCell" bundle:nil];        [tableView registerNib:nib forCellReuseIdentifier:CustomCellIdentifier];        nibsRegistered = YES;    }    ListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier];    cell.selectionStyle = UITableViewCellSelectionStyleNone;    [cell.lab setText:[self.array objectAtIndex:indexPath.row]];    return cell;}-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {    return 185;}



@interface ListTableViewCell : UITableViewCell@property(nonatomic,strong)IBOutlet UILabel *lab;@end


////  ListTableViewCell.m//  WeiNiXieShi////  Created by vshine on 14-5-18.//  Copyright (c) 2014年 wdl. All rights reserved.//#import "ListTableViewCell.h"@implementation ListTableViewCell- (void)awakeFromNib {    // Initialization code    self.lab.lineBreakMode = NSLineBreakByWordWrapping;    self.lab.numberOfLines = 0;}- (void)setSelected:(BOOL)selected animated:(BOOL)animated {    [super setSelected:selected animated:animated];}@end


如果要使用下拉刷新或上拉加载可以在Code4App中搜索MJ哥开源的一个封装很好用。


0 0