| | |
| | | _arrayImageData = arrayImageData; |
| | | if (arrayImageData) { |
| | | |
| | | // for (__strong UIView *view in [self.viewBG subviews]) { |
| | | // [view removeFromSuperview]; |
| | | // view = nil; |
| | | // } |
| | | // for (__strong UIView *view in [self.viewBG subviews]) { |
| | | // [view removeFromSuperview]; |
| | | // view = nil; |
| | | // } |
| | | |
| | | if ([self.viewBG subviews].count != 0) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | - (void)setArrayImageNormolData:(NSDictionary *)arrayImageNormolData { |
| | | _arrayImageNormolData = arrayImageNormolData; |
| | | if (arrayImageNormolData) { |
| | | if ([self.viewBG subviews].count != 0) { |
| | | return; |
| | | } |
| | | |
| | | for (int i = 0; i < [arrayImageNormolData[@"data"] count]; i++) { |
| | | [self.arrayImage addObject:arrayImageNormolData[@"data"][i][@"Picture"]]; |
| | | [self.arrayData addObject:arrayImageNormolData[@"data"][i]]; |
| | | } |
| | | |
| | | if (_arrayImage.count > 2) { |
| | | CWFlowLayout *flowLayout = [[CWFlowLayout alloc] initWithStyle:CWCarouselStyle_H_1]; |
| | | |
| | | |
| | | flowLayout.itemWidth = KScreenW - 20; |
| | | flowLayout.itemSpace_H = 5; |
| | | |
| | | CWCarousel *carousel = [[CWCarousel alloc] initWithFrame:CGRectMake(0, 0, KScreenW, 156) |
| | | delegate:self |
| | | datasource:self |
| | | flowLayout:flowLayout]; |
| | | |
| | | [self.viewBG addSubview:carousel]; |
| | | |
| | | carousel.isAuto = YES; |
| | | carousel.endless = YES; |
| | | |
| | | carousel.backgroundColor = [UIColor whiteColor]; |
| | | [carousel registerViewClass:[UICollectionViewCell class] identifier:@"cellId"]; |
| | | [carousel freshCarousel]; |
| | | [carousel.pageControl removeFromSuperview]; |
| | | self.carousel = carousel; |
| | | |
| | | |
| | | } else { |
| | | CGRect frame = CGRectMake(10, 0, KScreenW - 20, 156); |
| | | //if (images && images.count != 0) { |
| | | SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:frame delegate:self placeholderImage:BSKPlaceHolderImage]; |
| | | //cycleScrollView.imageURLStringsGroup = images; |
| | | cycleScrollView.localizationImageNamesGroup = _arrayImage; |
| | | cycleScrollView.placeholderImage = BSKPlaceHolderImage; |
| | | cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic; |
| | | cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter; |
| | | cycleScrollView.autoScrollTimeInterval = 5.0f; |
| | | cycleScrollView.currentPageDotColor = UICOLOR_FROM_RGB(0x159FFF, 1.0); |
| | | cycleScrollView.pageDotColor = UICOLOR_FROM_RGB(0xffffff, 0.5); |
| | | cycleScrollView.pageControlBottomOffset = 5; |
| | | cycleScrollView.layer.masksToBounds = YES; |
| | | cycleScrollView.layer.cornerRadius = 8; |
| | | if (self.arrayImage.count < 2) { |
| | | cycleScrollView.infiniteLoop = NO; |
| | | } |
| | | //[self.viewBannerBG addSubview:cycleScrollView]; |
| | | [self.viewBG addSubview:cycleScrollView]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | - (void)open { |
| | | if (self.carousel) { |
| | | [self.carousel controllerWillAppear]; |
| | |
| | | } |
| | | |
| | | - (void)CWCarousel:(CWCarousel *)carousel didSelectedAtIndex:(NSInteger)index { |
| | | NSLog(@"...%ld...", (long)index); |
| | | |
| | | if (_delegate && [_delegate respondsToSelector:@selector(onEventBaner:)]) { |
| | | [_delegate onEventBaner:self.arrayData[index]]; |
| | | } |
| | | } |
| | | |
| | | - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index { |
| | | |
| | | if (_delegate && [_delegate respondsToSelector:@selector(onEventBaner:)]) { |
| | | [_delegate onEventBaner:self.arrayData[index]]; |
| | | } |
| | | } |
| | | |
| | | - (UIView *)viewBG { |