首页 > 代码库 > 1110...video

1110...video

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1d9421 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c91b13 } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo } p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c32275 } p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #822e0e } p.p7 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px "PingFang SC"; color: #1d9421 } p.p8 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3d1d81 } p.p9 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px "PingFang SC"; color: #c91b13 } p.p10 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px "PingFang SC"; color: #22961c } p.p11 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1d9421; min-height: 21.0px } span.s1 { } span.s2 { font: 18.0px "PingFang SC" } span.s3 { color: #822e0e } span.s4 { color: #c32275 } span.s5 { color: #c91b13 } span.s6 { color: #000000 } span.s7 { font: 18.0px "PingFang SC"; color: #c91b13 } span.s8 { color: #1d9421 } span.s9 { font: 18.0px "PingFang SC"; color: #1d9421 } span.s10 { color: #0435ff } span.s11 { font: 18.0px Menlo } span.s12 { color: #6122ae } span.s13 { color: #539aa4 } span.s14 { color: #703daa } span.s15 { color: #3d1d81 } span.s16 { color: #294c50 } span.s17 { color: #78492a } span.s18 { font: 18.0px Menlo; color: #000000 } span.s19 { font: 18.0px Menlo; color: #703daa }</style>

//

//  VideoHomeController.m

//  Patient

//

//  Created by gzz on 16/11/8.

//  Copyright ? 2016 ShangYu. All rights reserved.

//

 

#import "VideoHomeController.h"

#import "MyHeaderView.h"

#import "MyFooterView.h"

@interface VideoHomeController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>

 

 

@property(strong,nonatomic)UICollectionView *myCollectionV;

@end

static NSString *indentifyVideo = @"indentify";

@implementation VideoHomeController

-(void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:YES];

  //TODO...

}

 

- (void)viewDidLoad {

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor lightGrayColor];

    self.title = @"视频点播";

    [self navBarVideo];

    [self dataOpens];

    [self makeUIVideo];

    

    [self dataRequestInterface];

}

 

#pragma mark 数据的初始化

-(void)dataOpens{

   

}

 

#pragma mark dataRequestInterface 数据请求的接口

-(void)dataRequestInterface{

    

    [MBProgressHUD showHUDAddedTo:self.view animated:YES];

    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];//gzz0617af

    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json", nil];

    manager.responseSerializer = [AFHTTPResponseSerializer serializer];

    NSString *Srurl = [NSString stringWithFormat:@"%@addCommentReply",Public_URLNew];//gzz1108

 

    NSMutableDictionary *dicm = [NSMutableDictionary dictionary];

    Dlpontlerexple *dlpo = [Dlpontlerexple shareIndence];

//    dicm[@"user_uuid"] = dlpo.uuidstring;

//    dicm[@"article_uuid"]= _uuidJiayuan;

//    dicm[@"comment"] = replyComment;

//    if (!_isComment) {

//        dicm[@"reply_uuid"] = _otherPersonUUID;

//    }

//    dicm[@"type"] =  @"3";

    [manager POST: Srurl  parameters:dicm progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

        NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];

        NSString *coder = [NSString stringWithFormat:@"%@",dic[@"code"]];

        if ([coder isEqualToString:@"1"]) {

            

            NSMutableArray * arr = [dic objectForKey:@"data"];

            if (arr.count>0) {

                

                

            }

            

        }else{

            [self showHint:[dic  objectForKey:@"message"]];

        }

        

        [MBProgressHUD hideHUDForView:self.view animated:YES];

        

        

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        

        [MBProgressHUD hideHUDForView:self.view animated:YES];

        

    }];

 

 

 

}

 

 

#pragma mark 界面

-(void)makeUIVideo{

//    scrollv = [[UIScrollView alloc]init];

//    scrollv.frame = CGRectMake(0, 84, SCREEN_WIDTH, SCREEN_HEIGHT-100);

//    scrollv.delegate = self;

//    scrollv.showsVerticalScrollIndicator = NO;

//    scrollv.showsHorizontalScrollIndicator = NO;

//    scrollv.contentOffset = CGPointMake(0, 0);

//    scrollv.backgroundColor = WHITECOLORS;// RGB(228, 228, 228);//[UIColor clearColor];

//    scrollv.contentSize = CGSizeMake(0, SCREEN_HEIGHT);

//    scrollv.scrollEnabled = NO;

//    [self.view addSubview:scrollv];

    

    [self collecetionVideo];

 

}

 

-(void)collecetionVideo{

    

    UICollectionViewFlowLayout *flowL = [UICollectionViewFlowLayout new];

    flowL.minimumInteritemSpacing = 0;

    flowL.minimumLineSpacing = 0;

    [flowL setScrollDirection:UICollectionViewScrollDirectionVertical];

    

    

    _myCollectionV = [[UICollectionView alloc]initWithFrame:CGRectMake (10, 0self.view.frame.size.width-20, self.view.frame.size.height) collectionViewLayout:flowL];

    _myCollectionV.delegate =self;

    _myCollectionV.dataSource =self;

    _myCollectionV.backgroundColor = RGB(188, 188, 188);//[UIColor yellowColor];

    _myCollectionV.showsVerticalScrollIndicator = NO;

    [self.view addSubview:_myCollectionV];

    

#pragma mark -- 注册单元格

    [_myCollectionV registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:indentifyVideo];

    

#pragma mark -- 注册头部视图

    [_myCollectionV registerClass:[MyHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];

#pragma mark -- 注册尾部视图

    [_myCollectionV registerClass:[MyFooterView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView"];

 

 

 

}

 

#pragma mark --UICollectionView dataSource

//有多少个Section

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView

{

    return 3;

}

 

//每个section有多少个元素

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section

{

    if (section == 0) {

        return 2;

    }else if(section ==1){

        return 3;

    }{

        return 4;

        

    }

}

//每个单元格的数据

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

{

    

    

    UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:indentifyVideo forIndexPath:indexPath];

    for (UIView *view in cell.contentView.subviews) {

        [view removeFromSuperview];

    }

    cell.backgroundColor = [UIColor purpleColor];

//    [cell sizeToFit];gzz1110

    [cell.contentView addSubview:[self cellIndex:(int)indexPath.item]];

    return cell;

}

 

 

#pragma mark 自定义item

-(UIView *)cellIndex:(NSInteger)index{

    

    CGFloat widthD = (SCREEN_WIDTH-30)/2;

    CGFloat height = widthD/1.61;

    

    UIView  *viewdd = [[UIView alloc]initWithFrame:CGRectMake(1, 1, widthD-2, height-2)];

    viewdd.backgroundColor = [UIColor whiteColor];

    

    UIImageView *imageViews = [[UIImageView alloc]initWithFrame:CGRectMake(1, 1, widthD-2, height-2)];

    imageViews.backgroundColor = [UIColor redColor];

    [viewdd addSubview:imageViews];

    

    UILabel *desLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(imageViews.frame)+10, widthD-2, 10)];

    desLabel.textColor = [UIColor blackColor];

    desLabel.numberOfLines=2;

    desLabel.font = [UIFont systemFontOfSize:16];

    [viewdd addSubview:desLabel];

    //    NSString *summary=[newsLIST objectForKey:@"title"];

    desLabel.text=@"大家看法的;快乐亲耳朵是否答复是积极电视剧解决的加减法";

    if (index == 2) {

        desLabel.text=@"大加减法dd答复顶顶顶顶份";

    }

    if (index == 1) {

        desLabel.text=@"大答复顶顶顶顶份";

    }

    [desLabel sizeToFit];

    

    

    UILabel *expertLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(imageViews.frame)+10+36+10, 80, 16)];

    expertLabel.textAlignment = NSTextAlignmentLeft;

    expertLabel.textColor = [UIColor lightGrayColor];

    expertLabel.font = [UIFont systemFontOfSize:14];

    expertLabel.text = @"张德来专家";

    [viewdd addSubview:expertLabel];

    expertLabel.backgroundColor = [UIColor yellowColor];

    

    

    UIView *liangView = [[UIView alloc]initWithFrame:CGRectMake(widthD-50, 12, 40, 16)];

    liangView.backgroundColor = [UIColor redColor];

    liangView.centerY = expertLabel.centerY;

    [viewdd addSubview:liangView];

    

    

    NSString *nums = @"123";

    UIImageView *image1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 20, 16)];

    image1.backgroundColor = [UIColor purpleColor];

    [liangView addSubview:image1];

    

    UILabel *label2 = [[UILabel alloc]init];

    label2.frame = CGRectMake(CGRectGetMaxY(image1.frame)+5, 1, 30, 16);

    label2.text = nums;

    label2.centerY = image1.centerY;

    label2.font = [UIFont systemFontOfSize:12];

    label2.backgroundColor = [UIColor purpleColor];

    [label2 sizeToFit];

    [liangView addSubview:label2];

    CGFloat liangX = widthD-image1.width-label2.width-10;

    

    liangView.frame = CGRectMake(liangX, liangView.y, image1.width+label2.width, liangView.height);

    

    

    expertLabel.frame = CGRectMake(expertLabel.x, expertLabel.y, liangX-5, expertLabel.height);

    

    

    viewdd.frame = CGRectMake(viewdd.frame.origin.x, viewdd.frame.origin.y, viewdd.frame.size.width, CGRectGetMaxY(expertLabel.frame)+10);

    return viewdd;

}

 

//每个cell的大小

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath

{

    

    CGFloat widthD = (SCREEN_WIDTH-30)/2;

//    CGFloat height = widthD/1.61+36+30+16+16;

    CGFloat height = widthD/1.61+36+30+16+16-16;

    return CGSizeMake(widthD, height);

}

 

 

 

 

 

 

//设置头尾部内容

-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath

{

    UICollectionReusableView *reusableView =nil;

    

    if (kind ==UICollectionElementKindSectionHeader) {

        //定制头部视图的内容

        MyHeaderView *headerV = (MyHeaderView *)[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"forIndexPath:indexPath];

        headerV.titleLab.text =@"专家讲座";

        headerV.moreLab.text = @"更多";

        

        //        NSInteger tagsImages = indexPath.section+indexPath.item;/

        headerV.moreIMageview.tag = indexPath.section*1108;

        headerV.moreIMageview.backgroundColor = [UIColor clearColor];

        NSLog(@"tag..-===第几个section.%ld.",indexPath.section*1108);

        UITapGestureRecognizer *ges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(gesTap:)];

        [headerV.moreIMageview addGestureRecognizer:ges];

        reusableView = headerV;

    }

    if (kind ==UICollectionElementKindSectionFooter){

        MyFooterView *footerV = (MyFooterView *)[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView"forIndexPath:indexPath];

        // footerV.titleLab.text =@"尾部视图";

        reusableView = footerV;

    }

    return reusableView;

}

#pragma mark 更多的事件点击

-(void)gesTap:(UITapGestureRecognizer *)ges{

    

    NSInteger tags = ges.view.tag/1108;

    NSLog(@"tag..-===第几个section.%ld.",tags);

    

    

}

 

 

//点击单元格

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

{

    NSLog(@"------nsectio---%ld/.item....%ld",indexPath.section,indexPath.item);

}

 

-(CGSize)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section

{

    

    return CGSizeMake(self.view.frame.size.width, 40);

    

}

//5s的适配

 

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{

    

    return CGSizeMake(self.view.frame.size.width, 10);

    

}

 

////距边界缩放大小

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section

{

    return UIEdgeInsetsMake(0, 0 , 0, 0);//分别为上、左、下、右

    

}

 

 

 

 

 

 

 

 

 

 

 

 

#pragma mark navbar及返回

-(void)navBarVideo{

    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"gdback3"] originalImage] style:UIBarButtonItemStylePlain target:self action:@selector(backClickVideo)];

    self.navigationItem.leftBarButtonItem=backItem;

    self.navigationController.interactivePopGestureRecognizer.delegate = nil;

}

 

-(void)backClickVideo{

    [self.navigationController popViewControllerAnimated:YES];

}

 

 

 

 

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

 

}

 

/*

#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

1110...video