非常简单好用的无限轮播

来源:互联网 发布:使命召唤账号数据异常 编辑:程序博客网 时间:2024/04/30 07:16

今天写东西用到无限轮播,用了一个别人的demo,功能看着特别全,也很好,但是仔细看图片自动轮播的时候不顺畅,然后就搜了一下好用的轮播,自己改了一下更符合平时用了,就记录一下吧,以后省的忘记了哈

demo:http://download.csdn.net/detail/tuwanli125/9470322

demo地址:https://github.com/tuwanli/UNLimitedRollDemo

这个无限轮播可以显示本地图片也可以显示网络图片

真的很简单也很好用

上需求代码展示用法:只需要选择你是用本地图片还是网络图片就ok了


#import "RollMainVC.h"

#import "BannerScrollView.h"

#import "HeaderModel.h"

@interface RollMainVC ()<didWithImageDelegate>

{

    

    BannerScrollView *banView;

}

@property (nonatomic,strong)NSMutableArray *array;

@property (nonatomic,strong)NSArray *netArr;

@property (nonatomic,copy)NSString *imageType;


@end


@implementation RollMainVC


- (void)viewDidLoad {

    [superviewDidLoad];

    

   /*

     *显示网络图片

     */

    NSDictionary *dict1 =@{@"image":@"http://www.pj-hospital.com/d/file/998885555544/2014-04-28/06cca200bf633ab6868e499a0657fec0.jpg",@"title":@"盘锦市中心医院"};

    NSDictionary *dict2 =@{@"image":@"http://www.pj-hospital.com/d/file/998885555544/2014-04-28/f23199a3db612e6e3758840b4a5a0753.jpg",@"title":@"院内展示"};

    NSDictionary *dict3 =@{@"image":@"http://www.pj-hospital.com/d/file/998885555544/2014-04-28/1893b9d20b9a0da0ca7c2f1747a5be72.jpg",@"title":@"鄂尔多斯市中心医院"};

    NSDictionary *dict4 =@{@"image":@"http://www.pj-hospital.com/d/file/998885555544/2014-04-28/4307e2e9d6a490821c8e99c23957e82d.jpg",@"title":@"桓仁中心医院"};

   _netArr= [[NSMutableArrayalloc]initWithObjects:dict1,dict2,dict3,dict4,nil];

    _imageType = @"网络";

   /*

     *显示本地图片

     */

    NSDictionary *dict5 =@{@"image":@"1",@"title":@"盘锦市中心医院"};

    NSDictionary *dict6 =@{@"image":@"2",@"title":@"院内展示"};

    NSDictionary *dict7 =@{@"image":@"3",@"title":@"鄂尔多斯市中心医院"};

    NSDictionary *dict8 =@{@"image":@"4",@"title":@"桓仁中心医院"};

    _imageType = @"本地";

   _netArr= [[NSMutableArrayalloc]initWithObjects:dict5,dict6,dict7,dict8,nil];

   /*

     代码如下

     */

    banView = [BannerScrollViewcreateHeader];

    banView.delegate =self;

    banView.imagetype =_imageType;

    banView.frame =CGRectMake(0,0, [UIScreenmainScreen].bounds.size.width,300);

    banView.imgArr =self.array;

    

    [self.viewaddSubview:banView];

    


}

- (NSArray *)array

{

   if (_array ==nil) {

       _array = [[NSMutableArrayalloc]init];

       for (NSDictionary *dictin_netArr) {

           HeaderModel *model = [[HeaderModelalloc]initWithHeaderModel:dict];

            [_arrayaddObject:model];

        }

    }

   return_array;

}

- (void)didImage:(NSInteger)index

{


   NSLog(@"点击第%d张图片",index+1);

}

- (void)didReceiveMemoryWarning {

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end



- (void)didImage:(NSInteger)index这个方法是点击图片的代理方法
想点击之后干点啥事自己决定吧骂人(妈咪妈咪哄哇咔咔)


1 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 看完鬼片害怕睡不着怎么办 晚上看了鬼片怎么办 说话不经过大脑考虑怎么办 我太受欢迎了怎么办动漫结局 狗胃不好总呕吐怎么办 比格犬晚上叫怎么办 玻尿酸隆鼻变宽了怎么办 打玻尿酸鼻子变宽怎么办 鼻炎的人感冒了怎么办 小孩上幼儿园反复感冒怎么办 3岁宝宝感冒鼻炎怎么办 鼻炎犯了鼻子不通气怎么办 食物呛到鼻子里怎么办 胃疼引起的焦虑怎么办 泰迪犬发生口腔亏痒怎么办? 俩鼻子都堵了怎么办 2岁宝宝鼻甲肿大怎么办 感冒10多天不好怎么办 宝妈鼻炎犯了怎么办 鼻炎犯了好多黄鼻涕怎么办 空调吹多了上火怎么办 宝宝感冒鼻塞流鼻涕口臭怎么办 怀孕了有鼻息肉怎么办 孕晚期鼻炎犯了怎么办 孕妇鼻炎犯了头疼怎么办 一岁宝宝有鼻炎怎么办 蒸馒头的面酸了怎么办 dnf点券充错账号了怎么办 英雄联盟点券充错区了怎么办 文玩鼻烟壶盖子松了怎么办 文胸磨腋下的肉怎么办 荷兰在窝里拉屎怎么办 宝宝把泡沫吃了怎么办 荷兰猪一直叫该怎么办 人吃了缓冲泡沫怎么办 不小心吃了泡沫怎么办 不想养荷兰猪了怎么办 刚买的乌龟死了怎么办 剪猫指甲出血了怎么办 猫吃了酸性植物怎么办 金鱼在缸底不动怎么办