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
  • 相关阅读:
    HDU 6071
    HDU 6073
    HDU 2124 Repair the Wall(贪心)
    HDU 2037 今年暑假不AC(贪心)
    HDU 1257 最少拦截系统(贪心)
    HDU 1789 Doing Homework again(贪心)
    HDU 1009 FatMouse' Trade(贪心)
    HDU 2216 Game III(BFS)
    HDU 1509 Windows Message Queue(队列)
    HDU 1081 To The Max(动态规划)
  • 原文地址:https://www.cnblogs.com/lidongq/p/3930302.html
Copyright © 2011-2022 走看看