图片列表显示

图片列表显示图片列表显示
//
// ChannelViewController.m // MyMangoTV // // Created by apple on 14-8-19. // Copyright (c) 2014年 戴维营教育. All rights reserved. // #import "ChannelViewController.h" #import "CommonTableViewCell.h" #import "CategoryView.h" @interface ChannelViewController ()<UITableViewDataSource,UITableViewDelegate> { UITableView *_tableView; NSArray *_titleArray; NSArray *_imageArray; } @end @implementation ChannelViewController - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor cyanColor]; _tableView=[[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain]; _tableView.delegate=self; _tableView.dataSource=self; _tableView.separatorStyle=UITableViewCellSeparatorStyleNone; [_tableView registerClass:[CommonTableViewCell class] forCellReuseIdentifier:@"cell"]; [self.view addSubview:_tableView]; _titleArray= @[@"综艺", @"新闻", @"电视剧", @"电影", @"音乐", @"动画片", @"出品方", @"爱芒果", @"VIP专区", @"花儿与少年"]; _imageArray=@[@"TVProgramIcon",@"NewsIcon",@"PartTabBarMVIcon",@"MoviesIcon",@"MusicsIcon",@"CartoonIcon",@"TravelIcon",@"ImgoShareIcon",@"VipIcon",@"HuaerYuShaonianIcon"]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (_titleArray.count%3) { return _titleArray.count/3+1; } else { return _titleArray.count/3; } } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 80; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier=@"cell"; CommonTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath]; NSInteger row=[self tableView:nil numberOfRowsInSection:0]; NSInteger count=(indexPath.row+1==row)?(_titleArray.count%3):3; cell.numberOfViewInCell=^(CommonTableViewCell *sender){ return count; }; cell.widthForCell=^CGFloat(CommonTableViewCell *sender,NSInteger index){ return 100; }; cell.viewForCell=^UIView*(CommonTableViewCell *sender,NSInteger index){ CategoryView *v=[[CategoryView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)]; v.imageView.image=[UIImage imageNamed:_imageArray[indexPath.row*3+index]]; v.label.text = _titleArray[indexPath.row * 3 + index]; if (indexPath.row * 3 + index==8) { v.vipImageView.image=[UIImage imageNamed:@"VipCornerIcon.png"]; } return v; }; cell.didSelectedView = ^(CommonTableViewCell *cell, NSInteger index){ NSLog(@"%@", _titleArray[indexPath.row * 3 + index]); }; return cell; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end

 

你可能感兴趣的:(图片)