码迷,mamicode.com
首页 > 其他好文 > 详细

图片列表显示

时间:2014-08-22 22:25:19      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   os   io   for   ar   

bubuko.com,布布扣bubuko.com,布布扣
//
// 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

 

图片列表显示

标签:des   style   blog   http   color   os   io   for   ar   

原文地址:http://www.cnblogs.com/lidongq/p/3930302.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!