zoukankan      html  css  js  c++  java
  • 图片列表显示


    //
    // 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
  • 相关阅读:
    2、从0开始学算法 时间/空间复杂度(如何知道你的代码性能如何?)
    1、从0开始学算法 概述
    机器学习(五):通俗易懂决策树与随机森林及代码实践
    机器学习(四):通俗理解支持向量机SVM及代码实践
    机器学习(三):理解逻辑回归及二分类、多分类代码实践
    HDU 2492 Ping pong (树状数组)
    yum更新失败
    webpack3配置rules的问题
    置顶帖汇总
    2021.07.03软件更新公告
  • 原文地址:https://www.cnblogs.com/lidongq/p/3930302.html
Copyright © 2011-2022 走看看