iOS开发中实现新闻图片的无限循环展示的方法

2020-01-14 18:56:03王旭

 

iOS开发中实现新闻图片的无限循环展示的方法

(3)新建一个xib文件,和自定义的cell做关联

iOS开发中实现新闻图片的无限循环展示的方法

代码设计如下:

   YYcell.h文件

复制代码
//
//  YYcell.h
//  08-无限滚动(新闻数据展示)
//

 

#import <UIKit/UIKit.h>

@class YYnews;
@interface YYcell : UICollectionViewCell
@property(nonatomic,strong)YYnews *news;
@end


 YYcell.m文件
复制代码
//
//  YYcell.m
//  08-无限滚动(新闻数据展示)
//

 

#import "YYcell.h"
#import "YYnews.h"

@interface YYcell ()
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end


复制代码
@implementation YYcell

 

-(void)setNews:(YYnews *)news
{
    _news=news;
    self.label.text=news.title;
    self.imageView.image=[UIImage imageNamed:news.icon];
}

@end


(4)在主控制器中的代码处理

 

  YYViewController.m文件

复制代码
//
//  YYViewController.m
//  
//
//  Created by apple on 14-8-3.
//  Copyright (c) 2014年 yangyong. All rights reserved.