43.小项目:微博 C部分

---------- CZViewController.m ----------

#import "CZViewController.h"

#import "CZStatuse.h"

#import "CZStatuesCell.h"

#import "CZStatuesFrame.h"


@interface CZViewController ()<UITableViewDataSource>


@property (strong, nonatomic) IBOutlet UITableView *tableView;

@property (nonatomic, strong) NSArray *statuseFrames;


@end


@implementation CZViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

}


- (BOOL)prefersStatusBarHidden

{

    return YES;

}


- (NSArray *)statuseFrames

{

    if (_statuseFrames == nil)

    {

        NSString *path = [[NSBundle mainBundle] pathForResource:@"weibo.plist" ofType:nil];

        NSArray *dictArray = [NSArray arrayWithContentsOfFile:path];

        NSMutableArray *statuseFrameArray = [NSMutableArray array];

        for (NSDictionary * dict in dictArray)

        {

            CZStatuse *statuse  = [CZStatuse statuseWithDict:dict];

            CZStatuesFrame *statuseFrame = [[CZStatuesFrame alloc]init];

            statuseFrame.statuse = statuse;

            [statuseFrameArray addObject:statuseFrame];

        }

        _statuseFrames = statuseFrameArray;

    }

    return _statuseFrames;

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    return self.statuseFrames.count;

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    CZStatuesCell * cell = [CZStatuesCell cellWithTableView:tableView];

    cell.statuesFrame = self.statuseFrames[indexPath.row];

    return cell;

}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{


    CZStatuesFrame *statuesFrame = self.statuseFrames[indexPath.row];

    return statuesFrame.cellHeight;

}


@end

 

posted @ 2015-08-10 23:42  我要选李白  阅读(216)  评论(0编辑  收藏  举报