非常簡單好用的無限輪播

今天寫東西用到無限輪播,用了一個別人的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這個方法是點擊圖片的代理方法
想點擊之後乾點啥事自己決定吧罵人(媽咪媽咪哄哇咔咔)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章