Commit 5ce74fef by lee

remove YYImage,Update ProductDetail

parent 602d2c14
......@@ -29,7 +29,7 @@ pod 'MZFormSheetPresentationController'
pod 'MJRefresh', '~> 3.1'
#pod 'AFNetworkActivityLogger'
pod 'SFFocusViewLayout', '~> 2.0'
pod 'YYWebImage'
#pod 'YYWebImage'
pod 'MagicalRecord','~> 2.2'
pod 'Mobile-Buy-SDK',:git => 'https://github.com/houweibin/mobile-buy-sdk-ios'
#pod 'Mobile-Buy-SDK',:path => '../Pods/mobile-buy-sdk-ios'
......
......@@ -2963,8 +2963,6 @@
"-l\"SDWebImage\"",
"-l\"SFFocusViewLayout\"",
"-l\"YYCache\"",
"-l\"YYImage\"",
"-l\"YYWebImage\"",
"-l\"c++\"",
"-l\"sqlite3\"",
"-l\"z\"",
......@@ -3037,8 +3035,6 @@
"-l\"SDWebImage\"",
"-l\"SFFocusViewLayout\"",
"-l\"YYCache\"",
"-l\"YYImage\"",
"-l\"YYWebImage\"",
"-l\"c++\"",
"-l\"sqlite3\"",
"-l\"z\"",
......
......@@ -10,13 +10,14 @@
#import "KWMImageUtil.h"
#import "KWMStringUtil.h"
#import "KWMPageControl.h"
#import "YYWebImage/YYWebImage.h"
//#import "YYWebImage/YYWebImage.h"
#import <SDCycleScrollView/SDCycleScrollView.h>
@interface KWMFirstDetailView ()<UIScrollViewDelegate>
@interface KWMFirstDetailView ()<SDCycleScrollViewDelegate>
@property(nonatomic,weak) IBOutlet UIView *vView;
@property(nonatomic,weak) IBOutlet UIScrollView *imageScrollView;
@property(nonatomic,weak) IBOutlet SDCycleScrollView *imageScrollView;
@property(nonatomic,weak) IBOutlet UIButton *btnBrand;
......@@ -31,7 +32,7 @@
//单位label
@property(nonatomic,weak) IBOutlet UILabel *lbUnit;
@property(nonatomic,weak) IBOutlet KWMPageControl *pageControl;
//@property(nonatomic,weak) IBOutlet KWMPageControl *pageControl;
@property (weak, nonatomic) IBOutlet UIView *sizeGuideView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *sizeGuideViewHeightConstraint;
......@@ -40,9 +41,9 @@
@property (nonatomic) NSMutableArray *imageArr;
@property (nonatomic) NSTimer *timer;
//@property (nonatomic) NSTimer *timer;
@property (nonatomic) BOOL isFirstScroll;
//@property (nonatomic) BOOL isFirstScroll;
@property (nonatomic) BOOL isShowCNY;
......@@ -91,50 +92,54 @@
NSLog(@"KWMProductDetailView%f%f",self.frame.size.width,self.frame.size.height);
self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vView];
}
-(void) addTimer{
if ([self.timer isValid]) {
return;
}
self.timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(doTimer) userInfo:nil repeats:YES];
[self.timer setFireDate:[NSDate new]];//开启
}
-(void) removeTimer{
//结束
if ([self.timer isValid]) {
[self.timer invalidate];
self.timer = nil;
}
self.imageScrollView.pageDotImage = [UIImage imageNamed:@"ic_page_1"];
self.imageScrollView.currentPageDotImage = [UIImage imageNamed:@"ic_page_2"];
self.imageScrollView.delegate = self;
self.imageScrollView.backgroundColor = [UIColor whiteColor];
}
//开始计时
-(void) doTimer{
if (self.isFirstScroll) {
self.isFirstScroll = NO;
return;
}
NSInteger currentIndex = self.pageControl.currentPage;
currentIndex ++;
currentIndex = currentIndex % self.pageControl.numberOfPages;
[self.imageScrollView setContentOffset:CGPointMake(UI_SCREEN_WIDTH * currentIndex, 0) animated:YES];
self.pageControl.currentPage = currentIndex;
}
//-(void) addTimer{
// if ([self.timer isValid]) {
// return;
// }
// self.timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(doTimer) userInfo:nil repeats:YES];
// [self.timer setFireDate:[NSDate new]];//开启
//}
//-(void) removeTimer{
// //结束
// if ([self.timer isValid]) {
// [self.timer invalidate];
// self.timer = nil;
// }
//}
//
////开始计时
//-(void) doTimer{
// if (self.isFirstScroll) {
// self.isFirstScroll = NO;
// return;
// }
// NSInteger currentIndex = self.pageControl.currentPage;
// currentIndex ++;
// currentIndex = currentIndex % self.pageControl.numberOfPages;
//// [self.imageScrollView setContentOffset:CGPointMake(UI_SCREEN_WIDTH * currentIndex, 0) animated:YES];
// self.pageControl.currentPage = currentIndex;
//}
-(void)setData:(BUYProduct *)product{
if(product == nil){
return;
}
self.isShowCNY = YES;
self.isFirstScroll = YES;
[self removeTimer];
// self.isFirstScroll = YES;
// [self removeTimer];
self.product = product;
self.imageScrollView.delegate = self;
[self.imageScrollView setContentOffset:CGPointMake(0, 0) animated:NO];
for (UIView *subview in self.imageScrollView.subviews) {
[subview removeFromSuperview];
}
// [self.imageScrollView setContentOffset:CGPointMake(0, 0) animated:NO];
// for (UIView *subview in self.imageScrollView.subviews) {
// [subview removeFromSuperview];
// }
[self initImage:product];
[self initView:product];
//[self addTimer];
......@@ -144,40 +149,43 @@
if(product == nil){
return;
}
[self.imageScrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
NSInteger imageCount = product.imagesArray == nil? 0:product.imagesArray.count;
self.imageArr = [NSMutableArray array];
CGFloat w = UI_SCREEN_WIDTH;
CGFloat h = UI_SCREEN_WIDTH;
for( int i =0;i < imageCount;i++){
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i*w, 0, w, h)];
imageView.tag = i;
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.clipsToBounds = YES;
NSString *imageUrl = [KWMImageUtil getProductImageUrlByPosition:self.product ImageSize:BigImage Position:i];
[self.imageArr addObject:imageUrl];
NSURL *imageURL = [NSURL URLWithString:imageUrl];
UITapGestureRecognizer *imageTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickImage:)];
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:imageTap];
if(i + 1 == imageCount){
[imageView yy_setImageWithURL:imageURL placeholder:nil options:YYWebImageOptionProgressive completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
if(image && !error){
[self performSelector:@selector(addTimer) withObject:nil afterDelay:0.5f];
}
}];
}else{
[imageView yy_setImageWithURL:imageURL options:YYWebImageOptionProgressive];
}
[self.imageScrollView addSubview:imageView];
}
self.pageControl.numberOfPages = imageCount;
self.pageControl.currentPage = 0;
self.pageControl.defaultImage = [UIImage imageNamed:@"ic_page_1"];
self.pageControl.currentImage = [UIImage imageNamed:@"ic_page_2"];
self.imageScrollView.contentSize = CGSizeMake(w*imageCount,0);
self.imageScrollView.pagingEnabled = YES;
// [self.imageScrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
// NSInteger imageCount = product.imagesArray == nil? 0:product.imagesArray.count;
// self.imageArr = [NSMutableArray array];
self.imageArr = [NSMutableArray arrayWithArray:[KWMImageUtil getProductImageUrls:self.product ImageSize:BigImage]];
self.imageScrollView.imageURLStringsGroup = self.imageArr;
// CGFloat w = UI_SCREEN_WIDTH;
// CGFloat h = UI_SCREEN_WIDTH;
// for( int i =0;i < imageCount;i++){
// UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i*w, 0, w, h)];
// imageView.tag = i;
// imageView.contentMode = UIViewContentModeScaleAspectFit;
// imageView.clipsToBounds = YES;
// NSString *imageUrl = [KWMImageUtil getProductImageUrlByPosition:self.product ImageSize:BigImage Position:i];
// [self.imageArr addObject:imageUrl];
// NSURL *imageURL = [NSURL URLWithString:imageUrl];
// UITapGestureRecognizer *imageTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickImage:)];
// imageView.userInteractionEnabled = YES;
// [imageView addGestureRecognizer:imageTap];
// if(i + 1 == imageCount){
// [imageView yy_setImageWithURL:imageURL placeholder:nil options:YYWebImageOptionProgressive completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
// if(image && !error){
// [self performSelector:@selector(addTimer) withObject:nil afterDelay:0.5f];
// }
// }];
// }else{
// [imageView yy_setImageWithURL:imageURL options:YYWebImageOptionProgressive];
// }
//
// [self.imageScrollView addSubview:imageView];
// }
// self.pageControl.numberOfPages = imageCount;
// self.pageControl.currentPage = 0;
// self.pageControl.defaultImage = [UIImage imageNamed:@"ic_page_1"];
// self.pageControl.currentImage = [UIImage imageNamed:@"ic_page_2"];
// self.imageScrollView.contentSize = CGSizeMake(w*imageCount,0);
// self.imageScrollView.pagingEnabled = YES;
}
......@@ -211,18 +219,22 @@
self.lbOldPrice.userInteractionEnabled = YES;
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
NSInteger index = fabs(scrollView.contentOffset.x)/scrollView.frame.size.width;
[self.pageControl setCurrentPage:index];
}
//-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
// NSInteger index = fabs(scrollView.contentOffset.x)/scrollView.frame.size.width;
// [self.pageControl setCurrentPage:index];
//}
-(void)onClickImage:(UITapGestureRecognizer *)tapGesture{
if(self.delegate!=nil){
UIView *view = [tapGesture view];
[self.delegate kwm_onClickImage:self.imageArr currentIndex:view.tag];
}
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
[self.delegate kwm_onClickImage:self.imageArr currentIndex:index];
}
//-(void)onClickImage:(UITapGestureRecognizer *)tapGesture{
// if(self.delegate!=nil){
// UIView *view = [tapGesture view];
// [self.delegate kwm_onClickImage:self.imageArr currentIndex:view.tag];
// }
//}
-(void)onClickPrice:(UITapGestureRecognizer *)tapGesture{
if(self.product == nil){
return;
......
......@@ -6,19 +6,17 @@
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMFirstDetailView">
<connections>
<outlet property="btnBrand" destination="s6N-a3-C4Z" id="ips-Jp-qG3"/>
<outlet property="imageScrollView" destination="h8J-3U-wMB" id="MbO-M3-YVy"/>
<outlet property="imageScrollView" destination="lKe-L4-ROK" id="V42-4B-a2B"/>
<outlet property="lbName" destination="SQm-rY-OyA" id="Fux-pg-fca"/>
<outlet property="lbOldPrice" destination="Mql-V1-hiE" id="Sh1-Fz-sfU"/>
<outlet property="lbPrice" destination="gpT-Sg-ghu" id="FGd-AA-Yiv"/>
<outlet property="lbVariant" destination="o3P-oH-Xcb" id="i3M-ae-jhH"/>
<outlet property="pageControl" destination="M6v-TN-2WE" id="QPe-TI-LdG"/>
<outlet property="sizeGuideView" destination="sRa-JA-uEq" id="D94-al-5dF"/>
<outlet property="sizeGuideViewHeightConstraint" destination="CLu-Pt-dGG" id="yih-xF-sL8"/>
<outlet property="vView" destination="iN0-l3-epB" id="TQD-W9-jEg"/>
......@@ -32,30 +30,11 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1H6-J2-jj4" userLabel="vContent">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lKe-L4-ROK" userLabel="vTop">
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lKe-L4-ROK" userLabel="vTop" customClass="SDCycleScrollView">
<rect key="frame" x="0.0" y="0.0" width="375" height="467"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="h8J-3U-wMB">
<rect key="frame" x="0.0" y="46.5" width="375" height="375"/>
<constraints>
<constraint firstAttribute="width" secondItem="h8J-3U-wMB" secondAttribute="height" multiplier="1:1" id="xTw-hD-9tf"/>
</constraints>
</scrollView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<constraints>
<constraint firstItem="h8J-3U-wMB" firstAttribute="centerY" secondItem="lKe-L4-ROK" secondAttribute="centerY" id="ZGl-tQ-ba8"/>
<constraint firstAttribute="trailing" secondItem="h8J-3U-wMB" secondAttribute="trailing" id="meb-bD-9hK"/>
<constraint firstItem="h8J-3U-wMB" firstAttribute="leading" secondItem="lKe-L4-ROK" secondAttribute="leading" id="snn-ZQ-b7q"/>
</constraints>
</view>
<pageControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" numberOfPages="3" translatesAutoresizingMaskIntoConstraints="NO" id="M6v-TN-2WE" customClass="KWMPageControl">
<rect key="frame" x="168" y="467" width="39" height="10"/>
<constraints>
<constraint firstAttribute="height" constant="10" id="n7t-N5-xKa"/>
</constraints>
</pageControl>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ymw-Cg-156" userLabel="vBottom">
<rect key="frame" x="0.0" y="477" width="375" height="190"/>
<subviews>
......@@ -306,15 +285,13 @@
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Ymw-Cg-156" firstAttribute="top" secondItem="M6v-TN-2WE" secondAttribute="bottom" id="5Y0-G8-3We"/>
<constraint firstAttribute="trailing" secondItem="Ymw-Cg-156" secondAttribute="trailing" id="6Mc-RC-ip7"/>
<constraint firstItem="M6v-TN-2WE" firstAttribute="top" secondItem="lKe-L4-ROK" secondAttribute="bottom" id="6oL-sd-1s7"/>
<constraint firstItem="Ymw-Cg-156" firstAttribute="top" secondItem="lKe-L4-ROK" secondAttribute="bottom" constant="10" id="Ge6-kP-hTq"/>
<constraint firstItem="lKe-L4-ROK" firstAttribute="top" secondItem="1H6-J2-jj4" secondAttribute="top" id="MVZ-Po-h2C"/>
<constraint firstAttribute="bottom" secondItem="Ymw-Cg-156" secondAttribute="bottom" id="Mef-7q-yrb"/>
<constraint firstItem="lKe-L4-ROK" firstAttribute="leading" secondItem="1H6-J2-jj4" secondAttribute="leading" id="bsW-GL-chq"/>
<constraint firstAttribute="trailing" secondItem="lKe-L4-ROK" secondAttribute="trailing" id="h7C-hB-wS6"/>
<constraint firstItem="Ymw-Cg-156" firstAttribute="leading" secondItem="1H6-J2-jj4" secondAttribute="leading" id="kHl-jZ-gRA"/>
<constraint firstItem="M6v-TN-2WE" firstAttribute="centerX" secondItem="1H6-J2-jj4" secondAttribute="centerX" id="mmR-Qc-1vL"/>
</constraints>
</view>
</subviews>
......
......@@ -56,7 +56,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2017083111</string>
<string>2017090411</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment