├── DCWebPicScrollView
├── demo
│ ├── 1.jpg
│ ├── 2.jpg
│ ├── 3.jpg
│ ├── 4.jpg
│ ├── 5.jpg
│ ├── 6.jpg
│ ├── 7.jpg
│ ├── place.png
│ ├── Untitled.gif
│ ├── ViewController.h
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ └── ViewController.m
├── main.m
├── DCPicscrollView
│ ├── DCWebImageManager.h
│ ├── DCPicScrollView.h
│ ├── DCWebImageManager.m
│ └── DCPicScrollView.m
├── Info.plist
└── Base.lproj
│ └── LaunchScreen.storyboard
├── DCWebPicScrollView.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
├── .gitignore
├── LICENSE
├── README.md
└── DCPicScrollView.m
/DCWebPicScrollView/demo/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MTLxDC/DCPicScrollView/HEAD/DCWebPicScrollView/demo/1.jpg
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MTLxDC/DCPicScrollView/HEAD/DCWebPicScrollView/demo/2.jpg
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MTLxDC/DCPicScrollView/HEAD/DCWebPicScrollView/demo/3.jpg
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MTLxDC/DCPicScrollView/HEAD/DCWebPicScrollView/demo/4.jpg
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MTLxDC/DCPicScrollView/HEAD/DCWebPicScrollView/demo/5.jpg
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MTLxDC/DCPicScrollView/HEAD/DCWebPicScrollView/demo/6.jpg
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MTLxDC/DCPicScrollView/HEAD/DCWebPicScrollView/demo/7.jpg
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/place.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MTLxDC/DCPicScrollView/HEAD/DCWebPicScrollView/demo/place.png
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/Untitled.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MTLxDC/DCPicScrollView/HEAD/DCWebPicScrollView/demo/Untitled.gif
--------------------------------------------------------------------------------
/DCWebPicScrollView.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // DCWebPicScrollView
4 | //
5 | // Created by dengchen on 15/12/4.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // DCWebPicScrollView
4 | //
5 | // Created by dengchen on 15/12/4.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // DCWebPicScrollView
4 | //
5 | // Created by dengchen on 15/12/4.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | #Pods/
27 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/DCPicscrollView/DCWebImageManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // DCWebImageManager.h
3 | // DCWebPicScrollView
4 | //
5 | // Created by dengchen on 15/12/7.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface DCWebImageManager : NSObject
12 |
13 |
14 |
15 | //只需要设置这2个就行了
16 |
17 | //下载失败重复下载次数,默认不重复,
18 | @property NSUInteger DownloadImageRepeatCount;
19 |
20 | //图片下载失败会调用该block(如果设置了重复下载次数,则会在重复下载完后,假如还没下载成功,就会调用该block)
21 | //error错误信息
22 | //url下载失败的imageurl
23 | @property (nonatomic,copy) void(^downLoadImageError)(NSError *error,NSString *imageUrl);
24 |
25 | @property (nonatomic,copy) void(^downLoadImageComplish)(UIImage *image,NSString *imageUrl);
26 |
27 |
28 | + (instancetype)shareManager;
29 |
30 | - (void)downloadImageWithUrlString:(NSString *)urlSting;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 NSDengChen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | NSAppTransportSecurity
38 |
39 | NSAllowsArbitraryLoads
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/DCPicscrollView/DCPicScrollView.h:
--------------------------------------------------------------------------------
1 | //
2 | // basePicScrollView.h
3 | // DCWebPicScrollView
4 | //
5 | // Created by dengchen on 15/12/5.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef NS_ENUM(NSUInteger, PageControlStyle) {
12 | PageControlAtCenter,
13 | PageControlAtRight,
14 | };
15 |
16 | @interface DCPicScrollView : UIView
17 |
18 | //占位图片
19 | @property (nonatomic,strong) UIImage *placeImage;
20 |
21 | @property (nonatomic,assign) NSTimeInterval AutoScrollDelay; //default is 2.0f,如果小于0.5不自动播放
22 |
23 | //设置PageControl位置
24 | @property (nonatomic,assign) PageControlStyle style; //default is PageControlAtCenter
25 |
26 | @property (nonatomic,copy) NSArray *titleData; //设置后显示label,自动设置PageControlAtRight
27 |
28 | //图片被点击会调用该block
29 | @property (nonatomic,copy) void(^imageViewDidTapAtIndex)(NSInteger index); //index从0开始
30 |
31 | /*@parameter imageUrl
32 | imageUrlString或imageName
33 | 网络加载urlsring必须为http:// 开头,
34 | //本地加载只需图片名字数组
35 | */
36 | + (instancetype)picScrollViewWithFrame:(CGRect)frame WithImageUrls:(NSArray *)imageUrl;
37 |
38 |
39 |
40 | @property (nonatomic,strong) UIColor *pageIndicatorTintColor;
41 |
42 | @property (nonatomic,strong) UIColor *currentPageIndicatorTintColor;
43 |
44 | //default is [[UIColor alloc] initWithWhite:0.5 alpha:1]
45 | @property (nonatomic,strong) UIColor *textColor;
46 |
47 | @property (nonatomic,strong) UIFont *font;
48 |
49 | @end
50 |
51 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // DCWebPicScrollView
4 | //
5 | // Created by dengchen on 15/12/4.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "ViewController.h"
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | _window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
20 |
21 | _window.rootViewController = [[ViewController alloc] init];
22 |
23 | [_window makeKeyAndVisible];
24 |
25 | return YES;
26 | }
27 |
28 | - (void)applicationWillResignActive:(UIApplication *)application {
29 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
30 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
31 | }
32 |
33 | - (void)applicationDidEnterBackground:(UIApplication *)application {
34 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
35 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
36 | }
37 |
38 | - (void)applicationWillEnterForeground:(UIApplication *)application {
39 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
40 | }
41 |
42 | - (void)applicationDidBecomeActive:(UIApplication *)application {
43 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
44 | }
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DCPicScrollView
2 |
3 |
4 |
5 |
6 |
7 |
8 | 喜欢加个star吧
9 | 
10 |
11 | 三个view复用,支持网络(有沙盒内存缓存)和本地加载,使用非常简单。
12 |
13 | ```Object-C
14 |
15 | - (void)demo1 {
16 |
17 | //网络加载
18 |
19 | NSArray *UrlStringArray = @[@"http://p1.qqyou.com/pic/UploadPic/2013-3/19/2013031923222781617.jpg",
20 | @"http://cdn.duitang.com/uploads/item/201409/27/20140927192649_NxVKT.thumb.700_0.png",
21 | @"http://img4.duitang.com/uploads/item/201409/27/20140927192458_GcRxV.jpeg",
22 | @"http://cdn.duitang.com/uploads/item/201304/20/20130420192413_TeRRP.thumb.700_0.jpeg"];
23 |
24 |
25 | NSArray *titleArray = [@"午夜寂寞 谁来陪我,唱一首动人的情歌.你问我说 快不快乐,唱情歌越唱越寂寞.谁明白我 想要什么,一瞬间释放的洒脱.灯光闪烁 不必啰嗦,我就是传说中的那个摇摆哥.我是摇摆哥 音乐会让我快乐,我是摇摆哥 我已忘掉了寂寞.我是摇摆哥 音乐会让我洒脱,我们一起唱这摇摆的歌" componentsSeparatedByString:@"."];
26 |
27 |
28 | //显示顺序和数组顺序一致
29 | //设置图片url数组,和滚动视图位置
30 |
31 | DCPicScrollView *picView = [DCPicScrollView picScrollViewWithFrame:CGRectMake(0, 0, self.view.frame.size.width, h * 2) WithImageUrls:UrlStringArray];
32 |
33 | //显示顺序和数组顺序一致
34 | //设置标题显示文本数组
35 |
36 |
37 |
38 | picView.titleData = titleArray;
39 |
40 | //占位图片,你可以在下载图片失败处修改占位图片
41 |
42 | picView.placeImage = [UIImage imageNamed:@"place.png"];
43 |
44 | //图片被点击事件,当前第几张图片被点击了,和数组顺序一致
45 |
46 | [picView setImageViewDidTapAtIndex:^(NSInteger index) {
47 | printf("第%zd张图片\n",index);
48 | }];
49 |
50 | //default is 2.0f,如果小于0.5不自动播放
51 | picView.AutoScrollDelay = 1.0f;
52 | // picView.textColor = [UIColor redColor];
53 |
54 | [self.view addSubview:picView];
55 |
56 | //下载失败重复下载次数,默认不重复,
57 | [[DCWebImageManager shareManager] setDownloadImageRepeatCount:1];
58 |
59 | //图片下载失败会调用该block(如果设置了重复下载次数,则会在重复下载完后,假如还没下载成功,就会调用该block)
60 | //error错误信息
61 | //url下载失败的imageurl
62 | [[DCWebImageManager shareManager] setDownLoadImageError:^(NSError *error, NSString *url) {
63 | NSLog(@"%@",error);
64 | }];
65 | }
66 |
67 |
68 |
69 |
70 | //本地加载只要放图片名数组就行了
71 |
72 | -(void)demo2 {
73 |
74 | NSMutableArray *arr2 = [[NSMutableArray alloc] init];
75 |
76 | NSMutableArray *arr3 = [[NSMutableArray alloc] init];
77 |
78 | for (int i = 1; i < 8; i++) {
79 | [arr2 addObject:[NSString stringWithFormat:@"%d.jpg",i]];
80 | [arr3 addObject:[NSString stringWithFormat:@"我是第%d张图片啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊",i]];
81 | };
82 |
83 |
84 | DCPicScrollView *picView1 = [DCPicScrollView picScrollViewWithFrame:CGRectMake(0,self.view.frame.size.height - h*2,self.view.frame.size.width, h) WithImageUrls:arr2];
85 |
86 | picView1.titleData = arr3;
87 |
88 | picView1.backgroundColor = [UIColor clearColor];
89 | [picView1 setImageViewDidTapAtIndex:^(NSInteger index) {
90 | printf("你点到我了😳index:%zd\n",index);
91 | }];
92 |
93 | picView1.AutoScrollDelay = 2.0f;
94 |
95 | [self.view addSubview:picView1];
96 | }
--------------------------------------------------------------------------------
/DCWebPicScrollView/demo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // DCWebPicScrollView
4 | //
5 | // Created by dengchen on 15/12/4.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "DCPicScrollView.h"
11 | #import "DCWebImageManager.h"
12 |
13 | @interface ViewController ()
14 |
15 | @end
16 |
17 | static CGFloat h = 50;
18 |
19 | @implementation ViewController
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 |
24 | self.view.backgroundColor = [UIColor whiteColor];
25 |
26 | [self demo1];
27 |
28 | [self demo2];
29 | }
30 |
31 | - (void)demo1 {
32 |
33 | //网络加载
34 |
35 | NSArray *UrlStringArray = @[@"http://p1.qqyou.com/pic/UploadPic/2013-3/19/2013031923222781617.jpg"];
36 |
37 |
38 | NSArray *titleArray = [@"午夜寂寞 谁来陪我,唱一首动人的情歌.你问我说 快不快乐,唱情歌越唱越寂寞.谁明白我 想要什么,一瞬间释放的洒脱.灯光闪烁 不必啰嗦,我就是传说中的那个摇摆哥.我是摇摆哥 音乐会让我快乐,我是摇摆哥 我已忘掉了寂寞.我是摇摆哥 音乐会让我洒脱,我们一起唱这摇摆的歌" componentsSeparatedByString:@"."];
39 |
40 |
41 | //显示顺序和数组顺序一致
42 | //设置图片url数组,和滚动视图位置
43 |
44 | DCPicScrollView *picView = [DCPicScrollView picScrollViewWithFrame:CGRectMake(0, 0, self.view.frame.size.width, h*2) WithImageUrls:UrlStringArray];
45 |
46 | //显示顺序和数组顺序一致
47 | //设置标题显示文本数组
48 |
49 |
50 |
51 | picView.titleData = titleArray;
52 |
53 | //占位图片,你可以在下载图片失败处修改占位图片
54 |
55 | // picView.placeImage = [UIImage imageNamed:@"place.png"];
56 |
57 | //图片被点击事件,当前第几张图片被点击了,和数组顺序一致
58 |
59 | [picView setImageViewDidTapAtIndex:^(NSInteger index) {
60 | printf("第%zd张图片\n",index);
61 | }];
62 |
63 | //default is 2.0f,如果小于0.5不自动播放
64 | picView.AutoScrollDelay = 1.0f;
65 | // picView.textColor = [UIColor redColor];
66 |
67 | [self.view addSubview:picView];
68 |
69 | //下载失败重复下载次数,默认不重复,
70 | [[DCWebImageManager shareManager] setDownloadImageRepeatCount:1];
71 |
72 | //图片下载失败会调用该block(如果设置了重复下载次数,则会在重复下载完后,假如还没下载成功,就会调用该block)
73 | //error错误信息
74 | //url下载失败的imageurl
75 | [[DCWebImageManager shareManager] setDownLoadImageError:^(NSError *error, NSString *url) {
76 | NSLog(@"%@",error);
77 | }];
78 | }
79 |
80 |
81 |
82 |
83 | //本地加载只要放图片名数组就行了
84 |
85 | -(void)demo2 {
86 |
87 | NSMutableArray *arr2 = [[NSMutableArray alloc] init];
88 |
89 | NSMutableArray *arr3 = [[NSMutableArray alloc] init];
90 |
91 | for (int i = 1; i < 2; i++) {
92 | [arr2 addObject:[NSString stringWithFormat:@"%d.jpg",i]];
93 | [arr3 addObject:[NSString stringWithFormat:@"我是第%d张图片啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊",i]];
94 | };
95 |
96 |
97 | DCPicScrollView *picView1 = [DCPicScrollView picScrollViewWithFrame:CGRectMake(0,self.view.frame.size.height - h*5,self.view.frame.size.width, h*2) WithImageUrls:arr2];
98 |
99 | picView1.style = PageControlAtCenter;
100 | picView1.titleData = arr3;
101 |
102 | picView1.backgroundColor = [UIColor clearColor];
103 | [picView1 setImageViewDidTapAtIndex:^(NSInteger index) {
104 | printf("你点到我了😳index:%zd\n",index);
105 | }];
106 |
107 | picView1.AutoScrollDelay = 2.0f;
108 |
109 | [self.view addSubview:picView1];
110 | }
111 |
112 | @end
113 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/DCPicscrollView/DCWebImageManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // DCWebImageManager.m
3 | // DCWebPicScrollView
4 | //
5 | // Created by dengchen on 15/12/7.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #import "DCWebImageManager.h"
10 |
11 | @interface DCWebImageManager ()
12 |
13 | @property (nonatomic,copy) NSString *cachePath;
14 |
15 | @property (nonatomic,strong) NSMutableDictionary *DownloadImageCount;
16 |
17 | @end
18 |
19 | @implementation DCWebImageManager
20 |
21 | + (instancetype)shareManager {
22 |
23 | static DCWebImageManager *instance;
24 |
25 | static dispatch_once_t onceToken;
26 | dispatch_once(&onceToken, ^{
27 | instance = [[DCWebImageManager alloc] init];
28 | });
29 |
30 | return instance;
31 | }
32 |
33 | #pragma mark downLoadImage
34 |
35 | - (BOOL)LoadDiskCacheWithUrlString:(NSString *)urlString {
36 | //取沙盒缓存
37 | NSData *data = [NSData dataWithContentsOfFile:[self.cachePath stringByAppendingPathComponent:urlString]];
38 |
39 | if (data.length > 0 ) {
40 |
41 | UIImage *image = [UIImage imageWithData:data];
42 |
43 | if (image) {
44 | if (self.downLoadImageComplish) {
45 | dispatch_async(dispatch_get_main_queue(), ^{
46 | self.downLoadImageComplish(image,urlString);
47 | });
48 | }
49 | return YES;
50 | }else {
51 | [[NSFileManager defaultManager] removeItemAtPath:[self.cachePath stringByAppendingPathComponent:urlString] error:NULL];
52 | }
53 | }
54 | return NO;
55 | }
56 |
57 |
58 | - (void)downloadImageWithUrlString:(NSString *)urlSting {
59 |
60 | if ([self LoadDiskCacheWithUrlString:urlSting]) {
61 | return;
62 | }
63 |
64 | if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) {
65 |
66 | [[[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:urlSting] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
67 |
68 | [self downLoadImagefinish:data
69 | url:urlSting
70 | error:error
71 | response:response];
72 |
73 | }] resume];
74 |
75 | }else {
76 |
77 | [NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlSting]] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
78 |
79 | [self downLoadImagefinish:data
80 | url:urlSting
81 | error:connectionError
82 | response:response];
83 | }] ;
84 |
85 | }
86 | }
87 |
88 |
89 |
90 | - (void)downLoadImagefinish:(NSData *)data url:(NSString *)urlString error:(NSError *)error response:(NSURLResponse *)response{
91 |
92 | if (error) {
93 | [self repeatDownLoadImage:urlString error:error];
94 | return ;
95 | }
96 |
97 | UIImage *image = [UIImage imageWithData:data];
98 |
99 |
100 | if (!image) {
101 |
102 | NSHTTPURLResponse *res = (NSHTTPURLResponse *)response;
103 | NSString *errorData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
104 |
105 | NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:@"错误数据字符串信息:%@\nhttp statusCode(错误代码):%zd",errorData,res.statusCode] code:0 userInfo:nil];
106 |
107 | [self repeatDownLoadImage:urlString error:error];
108 | return ;
109 | }
110 |
111 | // 沙盒缓存
112 | [data writeToFile:[self.cachePath stringByAppendingPathComponent:urlString] atomically:YES];
113 |
114 | if (self.downLoadImageComplish) {
115 | dispatch_async(dispatch_get_main_queue(), ^{
116 | self.downLoadImageComplish(image,urlString);
117 | });
118 | }
119 | }
120 |
121 | - (void)repeatDownLoadImage:(NSString *)urlString error:(NSError *)error{
122 |
123 | NSNumber *num = [self.DownloadImageCount objectForKey:urlString];
124 | NSInteger count = num ? [num integerValue] : 0;
125 |
126 | if (self.DownloadImageRepeatCount > count ) {
127 |
128 | [self.DownloadImageCount setObject:@(++count) forKey:urlString];
129 | [self downloadImageWithUrlString:urlString];
130 |
131 | }else {
132 |
133 | if (self.downLoadImageError) {
134 | self.downLoadImageError(error,urlString);
135 | }
136 | }
137 | }
138 |
139 |
140 |
141 | #pragma mark lazyload
142 |
143 |
144 | - (NSMutableDictionary *)DownloadImageCount {
145 | if (!_DownloadImageCount) {
146 | _DownloadImageCount = [NSMutableDictionary dictionary];
147 | }
148 | return _DownloadImageCount;
149 | }
150 |
151 | - (NSString *)cachePath {
152 | if (!_cachePath) {
153 |
154 | _cachePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:NSStringFromClass([self class])];
155 |
156 | [[NSFileManager defaultManager] createDirectoryAtPath:_cachePath withIntermediateDirectories:NO attributes:nil error:NULL];
157 |
158 | }
159 | return _cachePath;
160 | }
161 |
162 |
163 | @end
164 |
--------------------------------------------------------------------------------
/DCWebPicScrollView/DCPicscrollView/DCPicScrollView.m:
--------------------------------------------------------------------------------
1 | //
2 | // DCPicScrollView.m
3 | // DCPicScrollView
4 | //
5 | // Created by dengchen on 15/12/4.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #define myWidth self.frame.size.width
10 | #define myHeight self.frame.size.height
11 | #define pageSize (myHeight * 0.2 > 25 ? 25 : myHeight * 0.2)
12 |
13 | #import "DCPicScrollView.h"
14 | #import "DCWebImageManager.h"
15 |
16 |
17 | @interface DCPicScrollView ()
18 |
19 | @property (nonatomic,strong) NSMutableDictionary *imageData;
20 |
21 | @property (nonatomic,strong) NSArray *imageUrlStrings;
22 |
23 | @end
24 |
25 |
26 |
27 | @implementation DCPicScrollView{
28 |
29 | __weak UIImageView *_leftImageView,*_centerImageView,*_rightImageView;
30 |
31 | __weak UILabel *_titleLabel;
32 |
33 | __weak UIScrollView *_scrollView;
34 |
35 | __weak UIPageControl *_PageControl;
36 |
37 | NSTimer *_timer;
38 |
39 | NSInteger _currentIndex;
40 |
41 | NSInteger _MaxImageCount;
42 |
43 | BOOL _isNetwork;
44 |
45 | BOOL _hasTitle;
46 | }
47 |
48 |
49 | - (void)setMaxImageCount:(NSInteger)MaxImageCount {
50 | _MaxImageCount = MaxImageCount;
51 |
52 | [self prepareImageView];
53 | [self preparePageControl];
54 |
55 | [self setUpTimer];
56 |
57 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
58 | }
59 |
60 |
61 | - (void)imageViewDidTap {
62 | if (self.imageViewDidTapAtIndex != nil) {
63 | self.imageViewDidTapAtIndex(_currentIndex);
64 | }
65 | }
66 |
67 | + (instancetype)picScrollViewWithFrame:(CGRect)frame WithImageUrls:(NSArray *)imageUrl {
68 | return [[DCPicScrollView alloc] initWithFrame:frame WithImageNames:imageUrl];
69 | }
70 |
71 | - (instancetype)initWithFrame:(CGRect)frame WithImageNames:(NSArray *)ImageName {
72 | if (ImageName.count < 1) {
73 | return nil;
74 | }
75 |
76 | self = [super initWithFrame:frame];
77 |
78 | if(ImageName.count == 1) {
79 |
80 | UIImageView *img = [[UIImageView alloc] initWithFrame:self.bounds];
81 | [self addSubview:img];
82 | _centerImageView = img;
83 |
84 | UIView *titleView = [self creatLabelBgView];
85 |
86 | _titleLabel = (UILabel *)titleView.subviews.firstObject;
87 |
88 | [self addSubview:titleView];
89 | _isNetwork = [ImageName.firstObject hasPrefix:@"http://"];
90 |
91 | if (_isNetwork) {
92 | DCWebImageManager *manager = [DCWebImageManager shareManager];
93 |
94 | [manager setDownLoadImageComplish:^(UIImage *image, NSString *url) {
95 | img.image = image;
96 | }];
97 |
98 | [manager downloadImageWithUrlString:ImageName.firstObject];
99 |
100 | }else {
101 | img.image = [UIImage imageNamed:ImageName.firstObject];
102 | }
103 |
104 | return self;
105 | }
106 |
107 | [self prepareScrollView];
108 | [self setImageUrlStrings:ImageName];
109 | [self setMaxImageCount:self.imageUrlStrings.count];
110 |
111 | return self;
112 | }
113 |
114 |
115 | - (void)prepareScrollView {
116 |
117 | UIScrollView *sc = [[UIScrollView alloc] initWithFrame:self.bounds];
118 | [self addSubview:sc];
119 |
120 | _scrollView = sc;
121 | _scrollView.backgroundColor = [UIColor clearColor];
122 | _scrollView.pagingEnabled = YES;
123 | _scrollView.showsHorizontalScrollIndicator = NO;
124 | _scrollView.delegate = self;
125 |
126 | _scrollView.contentSize = CGSizeMake(myWidth * 3,0);
127 |
128 | _AutoScrollDelay = 2.0f;
129 | _currentIndex = 0;
130 | }
131 |
132 | - (void)prepareImageView {
133 |
134 | UIImageView *left = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0,myWidth, myHeight)];
135 | UIImageView *center = [[UIImageView alloc] initWithFrame:CGRectMake(myWidth, 0,myWidth, myHeight)];
136 | UIImageView *right = [[UIImageView alloc] initWithFrame:CGRectMake(myWidth * 2, 0,myWidth, myHeight)];
137 |
138 | center.userInteractionEnabled = YES;
139 | [center addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewDidTap)]];
140 |
141 | [_scrollView addSubview:left];
142 | [_scrollView addSubview:center];
143 | [_scrollView addSubview:right];
144 |
145 | _leftImageView = left;
146 | _centerImageView = center;
147 | _rightImageView = right;
148 |
149 | }
150 |
151 | - (void)preparePageControl {
152 |
153 | UIPageControl *page = [[UIPageControl alloc] initWithFrame:CGRectMake(0,myHeight - pageSize,myWidth, 7)];
154 |
155 | page.pageIndicatorTintColor = [UIColor lightGrayColor];
156 | page.currentPageIndicatorTintColor = [UIColor whiteColor];
157 | page.numberOfPages = _MaxImageCount;
158 | page.currentPage = 0;
159 |
160 | [self addSubview:page];
161 |
162 |
163 | _PageControl = page;
164 | }
165 |
166 | - (void)setStyle:(PageControlStyle)style {
167 | CGFloat w = _MaxImageCount * 17.5;
168 | _PageControl.frame = CGRectMake(0, 0, w, 7);
169 |
170 | if (style == PageControlAtRight || _hasTitle) {
171 | _PageControl.center = CGPointMake(myWidth-w*0.5, myHeight-pageSize * 0.5);
172 | }else if(style == PageControlAtCenter) {
173 | _PageControl.center = CGPointMake(myWidth * 0.5,myHeight-pageSize * 0.5);
174 | }
175 | }
176 |
177 | - (void)setPageIndicatorTintColor:(UIColor *)pageIndicatorTintColor {
178 | _PageControl.pageIndicatorTintColor = pageIndicatorTintColor;
179 | }
180 |
181 | - (void)setCurrentPageIndicatorTintColor:(UIColor *)currentPageIndicatorTintColor {
182 | _PageControl.currentPageIndicatorTintColor = currentPageIndicatorTintColor;
183 | }
184 |
185 |
186 | - (void)setTitleData:(NSArray *)titleData {
187 | if (titleData.count < 1) return;
188 |
189 | if (titleData.count == 1) {
190 | _titleLabel.text = titleData.firstObject;
191 | return;
192 | }
193 |
194 | if (titleData.count < _imageData.count) {
195 | NSMutableArray *temp = [NSMutableArray arrayWithArray:titleData];
196 | for (int i = 0; i < _imageData.count - titleData.count; i++) {
197 | [temp addObject:@""];
198 | }
199 | _titleData = temp;
200 | }else {
201 |
202 | _titleData = titleData;
203 | }
204 |
205 | [self prepareTitleLabel];
206 | _hasTitle = YES;
207 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
208 | }
209 |
210 |
211 | - (void)prepareTitleLabel {
212 |
213 | [self setStyle:PageControlAtRight];
214 |
215 | UIView *titleView = [self creatLabelBgView];
216 |
217 | _titleLabel = (UILabel *)titleView.subviews.firstObject;
218 |
219 | [self addSubview:titleView];
220 |
221 | [self bringSubviewToFront:_PageControl];
222 | }
223 |
224 |
225 |
226 | - (UIView *)creatLabelBgView {
227 |
228 |
229 | UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, myHeight-pageSize, myWidth, pageSize)];
230 | v.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
231 |
232 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(8,0, myWidth-_PageControl.frame.size.width-16,pageSize)];
233 | label.textAlignment = NSTextAlignmentLeft;
234 | label.backgroundColor = [UIColor clearColor];
235 | label.textColor = [UIColor whiteColor];
236 | label.font = [UIFont systemFontOfSize:pageSize*0.5];
237 |
238 | [v addSubview:label];
239 |
240 | return v;
241 | }
242 |
243 | - (void)setTextColor:(UIColor *)textColor {
244 | _titleLabel.textColor = textColor;
245 | }
246 |
247 | - (void)setFont:(UIFont *)font {
248 | _titleLabel.font = font;
249 | }
250 |
251 | #pragma mark scrollViewDelegate
252 |
253 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
254 | [self setUpTimer];
255 | }
256 |
257 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
258 | [self removeTimer];
259 | }
260 |
261 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
262 | [self changeImageWithOffset:scrollView.contentOffset.x];
263 | }
264 |
265 |
266 | - (void)changeImageWithOffset:(CGFloat)offsetX {
267 |
268 | if (offsetX >= myWidth * 2) {
269 | _currentIndex++;
270 |
271 | if (_currentIndex == _MaxImageCount-1) {
272 |
273 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:0];
274 |
275 | }else if (_currentIndex == _MaxImageCount) {
276 |
277 | _currentIndex = 0;
278 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
279 |
280 | }else {
281 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:_currentIndex+1];
282 | }
283 | _PageControl.currentPage = _currentIndex;
284 |
285 | }
286 |
287 | if (offsetX <= 0) {
288 | _currentIndex--;
289 |
290 | if (_currentIndex == 0) {
291 |
292 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
293 |
294 | }else if (_currentIndex == -1) {
295 |
296 | _currentIndex = _MaxImageCount-1;
297 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:0];
298 |
299 | }else {
300 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:_currentIndex+1];
301 | }
302 |
303 | _PageControl.currentPage = _currentIndex;
304 | }
305 |
306 | }
307 |
308 | - (void)changeImageLeft:(NSInteger)LeftIndex center:(NSInteger)centerIndex right:(NSInteger)rightIndex {
309 |
310 |
311 | _leftImageView.image = [self setImageWithIndex:LeftIndex];
312 | _centerImageView.image = [self setImageWithIndex:centerIndex];
313 | _rightImageView.image = [self setImageWithIndex:rightIndex];
314 |
315 |
316 | if (_hasTitle) {
317 | _titleLabel.text = [self.titleData objectAtIndex:centerIndex];
318 | }
319 |
320 | [_scrollView setContentOffset:CGPointMake(myWidth, 0)];
321 | }
322 |
323 | -(void)setPlaceImage:(UIImage *)placeImage {
324 | if (!_isNetwork) return;
325 |
326 | _placeImage = placeImage;
327 | if (_MaxImageCount < 2 && _centerImageView) {
328 | _centerImageView.image = _placeImage;
329 | }else {
330 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
331 | }
332 | }
333 |
334 |
335 |
336 | - (UIImage *)setImageWithIndex:(NSInteger)index {
337 | if (index < 0||index >= self.imageUrlStrings.count) {
338 | return _placeImage;
339 | }
340 | //从内存缓存中取,如果没有使用占位图片
341 | UIImage *image = [self.imageData objectForKey:self.imageUrlStrings[index]];
342 |
343 | return image ? image : _placeImage;
344 | }
345 |
346 |
347 | - (void)scorll {
348 | [_scrollView setContentOffset:CGPointMake(_scrollView.contentOffset.x + myWidth, 0) animated:YES];
349 | }
350 |
351 | - (void)setAutoScrollDelay:(NSTimeInterval)AutoScrollDelay {
352 | _AutoScrollDelay = AutoScrollDelay;
353 | [self removeTimer];
354 | [self setUpTimer];
355 | }
356 |
357 | - (void)setUpTimer {
358 | if (_AutoScrollDelay < 0.5||_timer != nil) return;
359 |
360 | _timer = [NSTimer timerWithTimeInterval:_AutoScrollDelay target:self selector:@selector(scorll) userInfo:nil repeats:YES];
361 | [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
362 | }
363 |
364 | - (void)removeTimer {
365 | if (_timer == nil) return;
366 | [_timer invalidate];
367 | _timer = nil;
368 | }
369 |
370 | - (void)setImageUrlStrings:(NSArray *)imageUrlStrings {
371 |
372 | _imageUrlStrings = imageUrlStrings;
373 | _imageData = [NSMutableDictionary dictionaryWithCapacity:_imageUrlStrings.count];
374 |
375 | _isNetwork = [imageUrlStrings.firstObject hasPrefix:@"http://"];
376 |
377 | if (_isNetwork) {
378 |
379 | DCWebImageManager *manager = [DCWebImageManager shareManager];
380 |
381 | [manager setDownLoadImageComplish:^(UIImage *image, NSString *url) {
382 | [self.imageData setObject:image forKey:url];
383 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:_currentIndex+1];
384 | }];
385 |
386 | for (NSString *urlSting in imageUrlStrings) {
387 | [manager downloadImageWithUrlString:urlSting];
388 | }
389 |
390 | }else {
391 |
392 | for (NSString *name in imageUrlStrings) {
393 | [self.imageData setObject:[UIImage imageNamed:name] forKey:name];
394 | }
395 |
396 |
397 | }
398 |
399 | }
400 |
401 |
402 |
403 | -(void)dealloc {
404 | [self removeTimer];
405 | }
406 |
407 | //
408 | //- (void)getImage {
409 | //
410 | // SDWebImageManager *manager = [SDWebImageManager sharedManager];
411 | //
412 | // for (NSString *urlString in _imageData) {
413 | //
414 | // [manager downloadImageWithURL:[NSURL URLWithString:urlString] options:SDWebImageHighPriority progress:NULL completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
415 | // if (error) {
416 | // NSLog(@"%@",error);
417 | // }
418 | // }];
419 | // }
420 | //
421 | //}
422 | //- (UIImage *)setImageWithIndex:(NSInteger)index {
423 | //
424 | // UIImage *image =
425 | // [[[SDWebImageManager sharedManager] imageCache] imageFromMemoryCacheForKey:_imageData[index]];
426 | // if (image) {
427 | // return image;
428 | // }else {
429 | // return _placeImage;
430 | // }
431 | //
432 | //}
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 | @end
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
--------------------------------------------------------------------------------
/DCPicScrollView.m:
--------------------------------------------------------------------------------
1 | //
2 | // DCPicScrollView.m
3 | // DCPicScrollView
4 | //
5 | // Created by dengchen on 15/12/4.
6 | // Copyright © 2015年 name. All rights reserved.
7 | //
8 |
9 | #define myWidth self.frame.size.width
10 | #define myHeight self.frame.size.height
11 | #define pageSize (myHeight * 0.2 > 25 ? 25 : myHeight * 0.2)
12 |
13 | #import "DCPicScrollView.h"
14 | #import "DCWebImageManager.h"
15 |
16 |
17 | @interface DCPicScrollView ()
18 |
19 | @property (nonatomic,strong) NSMutableDictionary *imageData;
20 |
21 | @property (nonatomic,strong) NSArray *imageUrlStrings;
22 |
23 | @end
24 |
25 |
26 |
27 | @implementation DCPicScrollView{
28 |
29 | __weak UIImageView *_leftImageView,*_centerImageView,*_rightImageView;
30 |
31 | __weak UILabel *_titleLabel;
32 |
33 | __weak UIScrollView *_scrollView;
34 |
35 | __weak UIPageControl *_PageControl;
36 |
37 | NSTimer *_timer;
38 |
39 | NSInteger _currentIndex;
40 |
41 | NSInteger _MaxImageCount;
42 |
43 | BOOL _isNetwork;
44 |
45 | BOOL _hasTitle;
46 | }
47 |
48 |
49 | - (void)setMaxImageCount:(NSInteger)MaxImageCount {
50 | _MaxImageCount = MaxImageCount;
51 |
52 | [self prepareImageView];
53 | [self preparePageControl];
54 |
55 | [self setUpTimer];
56 |
57 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
58 | }
59 |
60 |
61 | - (void)imageViewDidTap {
62 | if (self.imageViewDidTapAtIndex != nil) {
63 | self.imageViewDidTapAtIndex(_currentIndex);
64 | }
65 | }
66 |
67 | + (instancetype)picScrollViewWithFrame:(CGRect)frame WithImageUrls:(NSArray *)imageUrl {
68 | return [[DCPicScrollView alloc] initWithFrame:frame WithImageNames:imageUrl];
69 | }
70 |
71 | - (instancetype)initWithFrame:(CGRect)frame WithImageNames:(NSArray *)ImageName {
72 | if (ImageName.count < 1) {
73 | return nil;
74 | }
75 |
76 | self = [super initWithFrame:frame];
77 |
78 | if(ImageName.count == 1) {
79 |
80 | UIImageView *img = [[UIImageView alloc] initWithFrame:self.bounds];
81 | [self addSubview:img];
82 | _centerImageView = img;
83 |
84 | UIView *titleView = [self creatLabelBgView];
85 |
86 | _titleLabel = (UILabel *)titleView.subviews.firstObject;
87 |
88 | [self addSubview:titleView];
89 | _isNetwork = [ImageName.firstObject hasPrefix:@"http://"];
90 |
91 | if (_isNetwork) {
92 | DCWebImageManager *manager = [DCWebImageManager shareManager];
93 |
94 | [manager setDownLoadImageComplish:^(UIImage *image, NSString *url) {
95 | img.image = image;
96 | }];
97 |
98 | [manager downloadImageWithUrlString:ImageName.firstObject];
99 |
100 | }else {
101 | img.image = [UIImage imageNamed:ImageName.firstObject];
102 | }
103 |
104 | return self;
105 | }
106 |
107 | [self prepareScrollView];
108 | [self setImageUrlStrings:ImageName];
109 | [self setMaxImageCount:self.imageUrlStrings.count];
110 |
111 | return self;
112 | }
113 |
114 |
115 | - (void)prepareScrollView {
116 |
117 | UIScrollView *sc = [[UIScrollView alloc] initWithFrame:self.bounds];
118 | [self addSubview:sc];
119 |
120 | _scrollView = sc;
121 | _scrollView.backgroundColor = [UIColor clearColor];
122 | _scrollView.pagingEnabled = YES;
123 | _scrollView.showsHorizontalScrollIndicator = NO;
124 | _scrollView.delegate = self;
125 |
126 | _scrollView.contentSize = CGSizeMake(myWidth * 3,0);
127 |
128 | _AutoScrollDelay = 2.0f;
129 | _currentIndex = 0;
130 | }
131 |
132 | - (void)prepareImageView {
133 |
134 | UIImageView *left = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0,myWidth, myHeight)];
135 | UIImageView *center = [[UIImageView alloc] initWithFrame:CGRectMake(myWidth, 0,myWidth, myHeight)];
136 | UIImageView *right = [[UIImageView alloc] initWithFrame:CGRectMake(myWidth * 2, 0,myWidth, myHeight)];
137 |
138 | center.userInteractionEnabled = YES;
139 | [center addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewDidTap)]];
140 |
141 | [_scrollView addSubview:left];
142 | [_scrollView addSubview:center];
143 | [_scrollView addSubview:right];
144 |
145 | _leftImageView = left;
146 | _centerImageView = center;
147 | _rightImageView = right;
148 |
149 | }
150 |
151 | - (void)preparePageControl {
152 |
153 | UIPageControl *page = [[UIPageControl alloc] initWithFrame:CGRectMake(0,myHeight - pageSize,myWidth, 7)];
154 |
155 | page.pageIndicatorTintColor = [UIColor lightGrayColor];
156 | page.currentPageIndicatorTintColor = [UIColor whiteColor];
157 | page.numberOfPages = _MaxImageCount;
158 | page.currentPage = 0;
159 |
160 | [self addSubview:page];
161 |
162 |
163 | _PageControl = page;
164 | }
165 |
166 | - (void)setStyle:(PageControlStyle)style {
167 | CGFloat w = _MaxImageCount * 17.5;
168 | _PageControl.frame = CGRectMake(0, 0, w, 7);
169 |
170 | if (style == PageControlAtRight || _hasTitle) {
171 | _PageControl.center = CGPointMake(myWidth-w*0.5, myHeight-pageSize * 0.5);
172 | }else if(style == PageControlAtCenter) {
173 | _PageControl.center = CGPointMake(myWidth * 0.5,myHeight-pageSize * 0.5);
174 | }
175 | }
176 |
177 | - (void)setPageIndicatorTintColor:(UIColor *)pageIndicatorTintColor {
178 | _PageControl.pageIndicatorTintColor = pageIndicatorTintColor;
179 | }
180 |
181 | - (void)setCurrentPageIndicatorTintColor:(UIColor *)currentPageIndicatorTintColor {
182 | _PageControl.currentPageIndicatorTintColor = currentPageIndicatorTintColor;
183 | }
184 |
185 |
186 | - (void)setTitleData:(NSArray *)titleData {
187 | if (titleData.count < 1) return;
188 |
189 | if (titleData.count == 1) {
190 | _titleLabel.text = titleData.firstObject;
191 | return;
192 | }
193 |
194 | if (titleData.count < _imageData.count) {
195 | NSMutableArray *temp = [NSMutableArray arrayWithArray:titleData];
196 | for (int i = 0; i < _imageData.count - titleData.count; i++) {
197 | [temp addObject:@""];
198 | }
199 | _titleData = temp;
200 | }else {
201 |
202 | _titleData = titleData;
203 | }
204 |
205 | [self prepareTitleLabel];
206 | _hasTitle = YES;
207 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
208 | }
209 |
210 |
211 | - (void)prepareTitleLabel {
212 |
213 | [self setStyle:PageControlAtRight];
214 |
215 | UIView *titleView = [self creatLabelBgView];
216 |
217 | _titleLabel = (UILabel *)titleView.subviews.firstObject;
218 |
219 | [self addSubview:titleView];
220 |
221 | [self bringSubviewToFront:_PageControl];
222 | }
223 |
224 |
225 |
226 | - (UIView *)creatLabelBgView {
227 |
228 |
229 | UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, myHeight-pageSize, myWidth, pageSize)];
230 | v.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
231 |
232 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(8,0, myWidth-_PageControl.frame.size.width-16,pageSize)];
233 | label.textAlignment = NSTextAlignmentLeft;
234 | label.backgroundColor = [UIColor clearColor];
235 | label.textColor = [UIColor whiteColor];
236 | label.font = [UIFont systemFontOfSize:pageSize*0.5];
237 |
238 | [v addSubview:label];
239 |
240 | return v;
241 | }
242 |
243 | - (void)setTextColor:(UIColor *)textColor {
244 | _titleLabel.textColor = textColor;
245 | }
246 |
247 | - (void)setFont:(UIFont *)font {
248 | _titleLabel.font = font;
249 | }
250 |
251 | #pragma mark scrollViewDelegate
252 |
253 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
254 | [self setUpTimer];
255 | }
256 |
257 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
258 | [self removeTimer];
259 | }
260 |
261 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
262 | [self changeImageWithOffset:scrollView.contentOffset.x];
263 | }
264 |
265 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
266 | {
267 | [scrollView setContentOffset:CGPointMake(CGRectGetWidth(scrollView.frame), 0) animated:YES];
268 | }
269 |
270 | - (void)changeImageWithOffset:(CGFloat)offsetX {
271 |
272 | if (offsetX >= myWidth * 2) {
273 | _currentIndex++;
274 |
275 | if (_currentIndex == _MaxImageCount-1) {
276 |
277 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:0];
278 |
279 | }else if (_currentIndex == _MaxImageCount) {
280 |
281 | _currentIndex = 0;
282 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
283 |
284 | }else {
285 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:_currentIndex+1];
286 | }
287 | _PageControl.currentPage = _currentIndex;
288 |
289 | }
290 |
291 | if (offsetX <= 0) {
292 | _currentIndex--;
293 |
294 | if (_currentIndex == 0) {
295 |
296 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
297 |
298 | }else if (_currentIndex == -1) {
299 |
300 | _currentIndex = _MaxImageCount-1;
301 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:0];
302 |
303 | }else {
304 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:_currentIndex+1];
305 | }
306 |
307 | _PageControl.currentPage = _currentIndex;
308 | }
309 |
310 | }
311 |
312 | - (void)changeImageLeft:(NSInteger)LeftIndex center:(NSInteger)centerIndex right:(NSInteger)rightIndex {
313 |
314 |
315 | _leftImageView.image = [self setImageWithIndex:LeftIndex];
316 | _centerImageView.image = [self setImageWithIndex:centerIndex];
317 | _rightImageView.image = [self setImageWithIndex:rightIndex];
318 |
319 |
320 | if (_hasTitle) {
321 | _titleLabel.text = [self.titleData objectAtIndex:centerIndex];
322 | }
323 |
324 | [_scrollView setContentOffset:CGPointMake(myWidth, 0)];
325 | }
326 |
327 | -(void)setPlaceImage:(UIImage *)placeImage {
328 | if (!_isNetwork) return;
329 |
330 | _placeImage = placeImage;
331 | if (_MaxImageCount < 2 && _centerImageView) {
332 | _centerImageView.image = _placeImage;
333 | }else {
334 | [self changeImageLeft:_MaxImageCount-1 center:0 right:1];
335 | }
336 | }
337 |
338 |
339 |
340 | - (UIImage *)setImageWithIndex:(NSInteger)index {
341 | if (index < 0||index >= self.imageUrlStrings.count) {
342 | return _placeImage;
343 | }
344 | //从内存缓存中取,如果没有使用占位图片
345 | UIImage *image = [self.imageData objectForKey:self.imageUrlStrings[index]];
346 |
347 | return image ? image : _placeImage;
348 | }
349 |
350 |
351 | - (void)scorll {
352 | [_scrollView setContentOffset:CGPointMake(_scrollView.contentOffset.x + myWidth, 0) animated:YES];
353 | }
354 |
355 | - (void)setAutoScrollDelay:(NSTimeInterval)AutoScrollDelay {
356 | _AutoScrollDelay = AutoScrollDelay;
357 | [self removeTimer];
358 | [self setUpTimer];
359 | }
360 |
361 | - (void)setUpTimer {
362 | if (_AutoScrollDelay < 0.5||_timer != nil) return;
363 |
364 | _timer = [NSTimer timerWithTimeInterval:_AutoScrollDelay target:self selector:@selector(scorll) userInfo:nil repeats:YES];
365 | [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
366 | }
367 |
368 | - (void)removeTimer {
369 | if (_timer == nil) return;
370 | [_timer invalidate];
371 | _timer = nil;
372 | }
373 |
374 | - (void)setImageUrlStrings:(NSArray *)imageUrlStrings {
375 |
376 | _imageUrlStrings = imageUrlStrings;
377 | _imageData = [NSMutableDictionary dictionaryWithCapacity:_imageUrlStrings.count];
378 |
379 | _isNetwork = [imageUrlStrings.firstObject hasPrefix:@"http://"];
380 |
381 | if (_isNetwork) {
382 |
383 | DCWebImageManager *manager = [DCWebImageManager shareManager];
384 |
385 | [manager setDownLoadImageComplish:^(UIImage *image, NSString *url) {
386 | [self.imageData setObject:image forKey:url];
387 | [self changeImageLeft:_currentIndex-1 center:_currentIndex right:_currentIndex+1];
388 | }];
389 |
390 | for (NSString *urlSting in imageUrlStrings) {
391 | [manager downloadImageWithUrlString:urlSting];
392 | }
393 |
394 | }else {
395 |
396 | for (NSString *name in imageUrlStrings) {
397 | [self.imageData setObject:[UIImage imageNamed:name] forKey:name];
398 | }
399 |
400 |
401 | }
402 |
403 | }
404 |
405 |
406 |
407 | -(void)dealloc {
408 | [self removeTimer];
409 | }
410 |
411 | //
412 | //- (void)getImage {
413 | //
414 | // SDWebImageManager *manager = [SDWebImageManager sharedManager];
415 | //
416 | // for (NSString *urlString in _imageData) {
417 | //
418 | // [manager downloadImageWithURL:[NSURL URLWithString:urlString] options:SDWebImageHighPriority progress:NULL completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
419 | // if (error) {
420 | // NSLog(@"%@",error);
421 | // }
422 | // }];
423 | // }
424 | //
425 | //}
426 | //- (UIImage *)setImageWithIndex:(NSInteger)index {
427 | //
428 | // UIImage *image =
429 | // [[[SDWebImageManager sharedManager] imageCache] imageFromMemoryCacheForKey:_imageData[index]];
430 | // if (image) {
431 | // return image;
432 | // }else {
433 | // return _placeImage;
434 | // }
435 | //
436 | //}
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 | @end
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
--------------------------------------------------------------------------------
/DCWebPicScrollView.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 843F8E921C14238E0055C517 /* place.png in Resources */ = {isa = PBXBuildFile; fileRef = 843F8E911C14238E0055C517 /* place.png */; settings = {ASSET_TAGS = (); }; };
11 | 846448021C11B94E0026C67E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 846448011C11B94E0026C67E /* main.m */; };
12 | 846448101C11B94E0026C67E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8464480E1C11B94E0026C67E /* LaunchScreen.storyboard */; };
13 | 847D97FC1C269CE500ACABCD /* Untitled.gif in Resources */ = {isa = PBXBuildFile; fileRef = 847D97FB1C269CE500ACABCD /* Untitled.gif */; settings = {ASSET_TAGS = (); }; };
14 | 84AB633F1C156158004321E4 /* DCWebImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 84AB633E1C156158004321E4 /* DCWebImageManager.m */; settings = {ASSET_TAGS = (); }; };
15 | 84AC26801C129BA700F8C007 /* DCPicScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84AC267B1C129BA700F8C007 /* DCPicScrollView.m */; settings = {ASSET_TAGS = (); }; };
16 | 84AC268F1C129BB600F8C007 /* 1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 84AC26841C129BB600F8C007 /* 1.jpg */; settings = {ASSET_TAGS = (); }; };
17 | 84AC26901C129BB600F8C007 /* 2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 84AC26851C129BB600F8C007 /* 2.jpg */; settings = {ASSET_TAGS = (); }; };
18 | 84AC26911C129BB600F8C007 /* 3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 84AC26861C129BB600F8C007 /* 3.jpg */; settings = {ASSET_TAGS = (); }; };
19 | 84AC26921C129BB600F8C007 /* 4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 84AC26871C129BB600F8C007 /* 4.jpg */; settings = {ASSET_TAGS = (); }; };
20 | 84AC26931C129BB600F8C007 /* 5.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 84AC26881C129BB600F8C007 /* 5.jpg */; settings = {ASSET_TAGS = (); }; };
21 | 84AC26941C129BB600F8C007 /* 6.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 84AC26891C129BB600F8C007 /* 6.jpg */; settings = {ASSET_TAGS = (); }; };
22 | 84AC26951C129BB600F8C007 /* 7.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 84AC268A1C129BB600F8C007 /* 7.jpg */; settings = {ASSET_TAGS = (); }; };
23 | 84AC26961C129BB600F8C007 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 84AC268C1C129BB600F8C007 /* AppDelegate.m */; settings = {ASSET_TAGS = (); }; };
24 | 84AC26971C129BB600F8C007 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84AC268E1C129BB600F8C007 /* ViewController.m */; settings = {ASSET_TAGS = (); }; };
25 | /* End PBXBuildFile section */
26 |
27 | /* Begin PBXFileReference section */
28 | 843F8E911C14238E0055C517 /* place.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = place.png; sourceTree = ""; };
29 | 846447FD1C11B94E0026C67E /* DCWebPicScrollView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DCWebPicScrollView.app; sourceTree = BUILT_PRODUCTS_DIR; };
30 | 846448011C11B94E0026C67E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
31 | 8464480F1C11B94E0026C67E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
32 | 846448111C11B94E0026C67E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
33 | 847D97FB1C269CE500ACABCD /* Untitled.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = Untitled.gif; sourceTree = ""; };
34 | 84AB633D1C156158004321E4 /* DCWebImageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DCWebImageManager.h; sourceTree = ""; };
35 | 84AB633E1C156158004321E4 /* DCWebImageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DCWebImageManager.m; sourceTree = ""; };
36 | 84AC267A1C129BA700F8C007 /* DCPicScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DCPicScrollView.h; sourceTree = ""; };
37 | 84AC267B1C129BA700F8C007 /* DCPicScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DCPicScrollView.m; sourceTree = ""; };
38 | 84AC26841C129BB600F8C007 /* 1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 1.jpg; sourceTree = ""; };
39 | 84AC26851C129BB600F8C007 /* 2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 2.jpg; sourceTree = ""; };
40 | 84AC26861C129BB600F8C007 /* 3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 3.jpg; sourceTree = ""; };
41 | 84AC26871C129BB600F8C007 /* 4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 4.jpg; sourceTree = ""; };
42 | 84AC26881C129BB600F8C007 /* 5.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 5.jpg; sourceTree = ""; };
43 | 84AC26891C129BB600F8C007 /* 6.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 6.jpg; sourceTree = ""; };
44 | 84AC268A1C129BB600F8C007 /* 7.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 7.jpg; sourceTree = ""; };
45 | 84AC268B1C129BB600F8C007 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
46 | 84AC268C1C129BB600F8C007 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
47 | 84AC268D1C129BB600F8C007 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
48 | 84AC268E1C129BB600F8C007 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
49 | /* End PBXFileReference section */
50 |
51 | /* Begin PBXFrameworksBuildPhase section */
52 | 846447FA1C11B94E0026C67E /* Frameworks */ = {
53 | isa = PBXFrameworksBuildPhase;
54 | buildActionMask = 2147483647;
55 | files = (
56 | );
57 | runOnlyForDeploymentPostprocessing = 0;
58 | };
59 | /* End PBXFrameworksBuildPhase section */
60 |
61 | /* Begin PBXGroup section */
62 | 846447F41C11B94E0026C67E = {
63 | isa = PBXGroup;
64 | children = (
65 | 846447FF1C11B94E0026C67E /* DCWebPicScrollView */,
66 | 846447FE1C11B94E0026C67E /* Products */,
67 | );
68 | sourceTree = "";
69 | };
70 | 846447FE1C11B94E0026C67E /* Products */ = {
71 | isa = PBXGroup;
72 | children = (
73 | 846447FD1C11B94E0026C67E /* DCWebPicScrollView.app */,
74 | );
75 | name = Products;
76 | sourceTree = "";
77 | };
78 | 846447FF1C11B94E0026C67E /* DCWebPicScrollView */ = {
79 | isa = PBXGroup;
80 | children = (
81 | 8464480E1C11B94E0026C67E /* LaunchScreen.storyboard */,
82 | 84AC26831C129BB600F8C007 /* demo */,
83 | 84AC26791C129BA700F8C007 /* DCPicscrollView */,
84 | 846448111C11B94E0026C67E /* Info.plist */,
85 | 846448001C11B94E0026C67E /* Supporting Files */,
86 | );
87 | path = DCWebPicScrollView;
88 | sourceTree = "";
89 | };
90 | 846448001C11B94E0026C67E /* Supporting Files */ = {
91 | isa = PBXGroup;
92 | children = (
93 | 846448011C11B94E0026C67E /* main.m */,
94 | );
95 | name = "Supporting Files";
96 | sourceTree = "";
97 | };
98 | 84AC26791C129BA700F8C007 /* DCPicscrollView */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 84AC267A1C129BA700F8C007 /* DCPicScrollView.h */,
102 | 84AC267B1C129BA700F8C007 /* DCPicScrollView.m */,
103 | 84AB633D1C156158004321E4 /* DCWebImageManager.h */,
104 | 84AB633E1C156158004321E4 /* DCWebImageManager.m */,
105 | );
106 | path = DCPicscrollView;
107 | sourceTree = "";
108 | };
109 | 84AC26831C129BB600F8C007 /* demo */ = {
110 | isa = PBXGroup;
111 | children = (
112 | 84AC26841C129BB600F8C007 /* 1.jpg */,
113 | 84AC26851C129BB600F8C007 /* 2.jpg */,
114 | 84AC26861C129BB600F8C007 /* 3.jpg */,
115 | 84AC26871C129BB600F8C007 /* 4.jpg */,
116 | 84AC26881C129BB600F8C007 /* 5.jpg */,
117 | 84AC26891C129BB600F8C007 /* 6.jpg */,
118 | 84AC268A1C129BB600F8C007 /* 7.jpg */,
119 | 843F8E911C14238E0055C517 /* place.png */,
120 | 847D97FB1C269CE500ACABCD /* Untitled.gif */,
121 | 84AC268B1C129BB600F8C007 /* AppDelegate.h */,
122 | 84AC268C1C129BB600F8C007 /* AppDelegate.m */,
123 | 84AC268D1C129BB600F8C007 /* ViewController.h */,
124 | 84AC268E1C129BB600F8C007 /* ViewController.m */,
125 | );
126 | path = demo;
127 | sourceTree = "";
128 | };
129 | /* End PBXGroup section */
130 |
131 | /* Begin PBXNativeTarget section */
132 | 846447FC1C11B94E0026C67E /* DCWebPicScrollView */ = {
133 | isa = PBXNativeTarget;
134 | buildConfigurationList = 846448141C11B94E0026C67E /* Build configuration list for PBXNativeTarget "DCWebPicScrollView" */;
135 | buildPhases = (
136 | 846447F91C11B94E0026C67E /* Sources */,
137 | 846447FA1C11B94E0026C67E /* Frameworks */,
138 | 846447FB1C11B94E0026C67E /* Resources */,
139 | );
140 | buildRules = (
141 | );
142 | dependencies = (
143 | );
144 | name = DCWebPicScrollView;
145 | productName = DCWebPicScrollView;
146 | productReference = 846447FD1C11B94E0026C67E /* DCWebPicScrollView.app */;
147 | productType = "com.apple.product-type.application";
148 | };
149 | /* End PBXNativeTarget section */
150 |
151 | /* Begin PBXProject section */
152 | 846447F51C11B94E0026C67E /* Project object */ = {
153 | isa = PBXProject;
154 | attributes = {
155 | LastUpgradeCheck = 0700;
156 | ORGANIZATIONNAME = name;
157 | TargetAttributes = {
158 | 846447FC1C11B94E0026C67E = {
159 | CreatedOnToolsVersion = 7.0;
160 | DevelopmentTeam = MABMSRRB25;
161 | };
162 | };
163 | };
164 | buildConfigurationList = 846447F81C11B94E0026C67E /* Build configuration list for PBXProject "DCWebPicScrollView" */;
165 | compatibilityVersion = "Xcode 3.2";
166 | developmentRegion = English;
167 | hasScannedForEncodings = 0;
168 | knownRegions = (
169 | en,
170 | Base,
171 | );
172 | mainGroup = 846447F41C11B94E0026C67E;
173 | productRefGroup = 846447FE1C11B94E0026C67E /* Products */;
174 | projectDirPath = "";
175 | projectRoot = "";
176 | targets = (
177 | 846447FC1C11B94E0026C67E /* DCWebPicScrollView */,
178 | );
179 | };
180 | /* End PBXProject section */
181 |
182 | /* Begin PBXResourcesBuildPhase section */
183 | 846447FB1C11B94E0026C67E /* Resources */ = {
184 | isa = PBXResourcesBuildPhase;
185 | buildActionMask = 2147483647;
186 | files = (
187 | 84AC26941C129BB600F8C007 /* 6.jpg in Resources */,
188 | 84AC26901C129BB600F8C007 /* 2.jpg in Resources */,
189 | 846448101C11B94E0026C67E /* LaunchScreen.storyboard in Resources */,
190 | 84AC26951C129BB600F8C007 /* 7.jpg in Resources */,
191 | 84AC268F1C129BB600F8C007 /* 1.jpg in Resources */,
192 | 843F8E921C14238E0055C517 /* place.png in Resources */,
193 | 84AC26931C129BB600F8C007 /* 5.jpg in Resources */,
194 | 84AC26921C129BB600F8C007 /* 4.jpg in Resources */,
195 | 84AC26911C129BB600F8C007 /* 3.jpg in Resources */,
196 | 847D97FC1C269CE500ACABCD /* Untitled.gif in Resources */,
197 | );
198 | runOnlyForDeploymentPostprocessing = 0;
199 | };
200 | /* End PBXResourcesBuildPhase section */
201 |
202 | /* Begin PBXSourcesBuildPhase section */
203 | 846447F91C11B94E0026C67E /* Sources */ = {
204 | isa = PBXSourcesBuildPhase;
205 | buildActionMask = 2147483647;
206 | files = (
207 | 84AC26971C129BB600F8C007 /* ViewController.m in Sources */,
208 | 846448021C11B94E0026C67E /* main.m in Sources */,
209 | 84AC26801C129BA700F8C007 /* DCPicScrollView.m in Sources */,
210 | 84AB633F1C156158004321E4 /* DCWebImageManager.m in Sources */,
211 | 84AC26961C129BB600F8C007 /* AppDelegate.m in Sources */,
212 | );
213 | runOnlyForDeploymentPostprocessing = 0;
214 | };
215 | /* End PBXSourcesBuildPhase section */
216 |
217 | /* Begin PBXVariantGroup section */
218 | 8464480E1C11B94E0026C67E /* LaunchScreen.storyboard */ = {
219 | isa = PBXVariantGroup;
220 | children = (
221 | 8464480F1C11B94E0026C67E /* Base */,
222 | );
223 | name = LaunchScreen.storyboard;
224 | sourceTree = "";
225 | };
226 | /* End PBXVariantGroup section */
227 |
228 | /* Begin XCBuildConfiguration section */
229 | 846448121C11B94E0026C67E /* Debug */ = {
230 | isa = XCBuildConfiguration;
231 | buildSettings = {
232 | ALWAYS_SEARCH_USER_PATHS = NO;
233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
234 | CLANG_CXX_LIBRARY = "libc++";
235 | CLANG_ENABLE_MODULES = YES;
236 | CLANG_ENABLE_OBJC_ARC = YES;
237 | CLANG_WARN_BOOL_CONVERSION = YES;
238 | CLANG_WARN_CONSTANT_CONVERSION = YES;
239 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
240 | CLANG_WARN_EMPTY_BODY = YES;
241 | CLANG_WARN_ENUM_CONVERSION = YES;
242 | CLANG_WARN_INT_CONVERSION = YES;
243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
244 | CLANG_WARN_UNREACHABLE_CODE = YES;
245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
246 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
247 | COPY_PHASE_STRIP = NO;
248 | DEBUG_INFORMATION_FORMAT = dwarf;
249 | ENABLE_STRICT_OBJC_MSGSEND = YES;
250 | ENABLE_TESTABILITY = YES;
251 | GCC_C_LANGUAGE_STANDARD = gnu99;
252 | GCC_DYNAMIC_NO_PIC = NO;
253 | GCC_NO_COMMON_BLOCKS = YES;
254 | GCC_OPTIMIZATION_LEVEL = 0;
255 | GCC_PREPROCESSOR_DEFINITIONS = (
256 | "DEBUG=1",
257 | "$(inherited)",
258 | );
259 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
260 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
261 | GCC_WARN_UNDECLARED_SELECTOR = YES;
262 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
263 | GCC_WARN_UNUSED_FUNCTION = YES;
264 | GCC_WARN_UNUSED_VARIABLE = YES;
265 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
266 | MTL_ENABLE_DEBUG_INFO = YES;
267 | ONLY_ACTIVE_ARCH = YES;
268 | SDKROOT = iphoneos;
269 | };
270 | name = Debug;
271 | };
272 | 846448131C11B94E0026C67E /* Release */ = {
273 | isa = XCBuildConfiguration;
274 | buildSettings = {
275 | ALWAYS_SEARCH_USER_PATHS = NO;
276 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
277 | CLANG_CXX_LIBRARY = "libc++";
278 | CLANG_ENABLE_MODULES = YES;
279 | CLANG_ENABLE_OBJC_ARC = YES;
280 | CLANG_WARN_BOOL_CONVERSION = YES;
281 | CLANG_WARN_CONSTANT_CONVERSION = YES;
282 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
283 | CLANG_WARN_EMPTY_BODY = YES;
284 | CLANG_WARN_ENUM_CONVERSION = YES;
285 | CLANG_WARN_INT_CONVERSION = YES;
286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
287 | CLANG_WARN_UNREACHABLE_CODE = YES;
288 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
289 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
290 | COPY_PHASE_STRIP = NO;
291 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
292 | ENABLE_NS_ASSERTIONS = NO;
293 | ENABLE_STRICT_OBJC_MSGSEND = YES;
294 | GCC_C_LANGUAGE_STANDARD = gnu99;
295 | GCC_NO_COMMON_BLOCKS = YES;
296 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
297 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
298 | GCC_WARN_UNDECLARED_SELECTOR = YES;
299 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
300 | GCC_WARN_UNUSED_FUNCTION = YES;
301 | GCC_WARN_UNUSED_VARIABLE = YES;
302 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
303 | MTL_ENABLE_DEBUG_INFO = NO;
304 | SDKROOT = iphoneos;
305 | VALIDATE_PRODUCT = YES;
306 | };
307 | name = Release;
308 | };
309 | 846448151C11B94E0026C67E /* Debug */ = {
310 | isa = XCBuildConfiguration;
311 | buildSettings = {
312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
313 | INFOPLIST_FILE = DCWebPicScrollView/Info.plist;
314 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
315 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
316 | PRODUCT_BUNDLE_IDENTIFIER = cn.name.DCWebPicScrollView;
317 | PRODUCT_NAME = "$(TARGET_NAME)";
318 | };
319 | name = Debug;
320 | };
321 | 846448161C11B94E0026C67E /* Release */ = {
322 | isa = XCBuildConfiguration;
323 | buildSettings = {
324 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
325 | INFOPLIST_FILE = DCWebPicScrollView/Info.plist;
326 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
327 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
328 | PRODUCT_BUNDLE_IDENTIFIER = cn.name.DCWebPicScrollView;
329 | PRODUCT_NAME = "$(TARGET_NAME)";
330 | };
331 | name = Release;
332 | };
333 | /* End XCBuildConfiguration section */
334 |
335 | /* Begin XCConfigurationList section */
336 | 846447F81C11B94E0026C67E /* Build configuration list for PBXProject "DCWebPicScrollView" */ = {
337 | isa = XCConfigurationList;
338 | buildConfigurations = (
339 | 846448121C11B94E0026C67E /* Debug */,
340 | 846448131C11B94E0026C67E /* Release */,
341 | );
342 | defaultConfigurationIsVisible = 0;
343 | defaultConfigurationName = Release;
344 | };
345 | 846448141C11B94E0026C67E /* Build configuration list for PBXNativeTarget "DCWebPicScrollView" */ = {
346 | isa = XCConfigurationList;
347 | buildConfigurations = (
348 | 846448151C11B94E0026C67E /* Debug */,
349 | 846448161C11B94E0026C67E /* Release */,
350 | );
351 | defaultConfigurationIsVisible = 0;
352 | defaultConfigurationName = Release;
353 | };
354 | /* End XCConfigurationList section */
355 | };
356 | rootObject = 846447F51C11B94E0026C67E /* Project object */;
357 | }
358 |
--------------------------------------------------------------------------------