GithubHelp home page GithubHelp logo

Comments (5)

codingZero avatar codingZero commented on May 28, 2024

@wyhazq 你好,我这边测试了一下,并未发现此问题

from xrcarouselview.

wyhazq avatar wyhazq commented on May 28, 2024

刚查了一下,应该是我的问题,我一开始传了3张placeholder的图片进去,用错了,不好意思

from xrcarouselview.

wyhazq avatar wyhazq commented on May 28, 2024

您好,还是这个bug,跟其他东西无关。重现方法:
1.首先后台返回两张图片,显示正确。
2.后台去掉第一张图片
3.客户端reload的时候,我调用self.carouselView.imageArray = images;
4.你那边调用

- (void)downloadImages:(int)index {
    NSString *key = _imageArray[index];
    //从沙盒中取图片
    NSString *path = [[[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"XRCarousel"] stringByAppendingPathComponent:[key lastPathComponent]];
    NSData *data = [NSData dataWithContentsOfFile:path];
    if (data) {
        _images[index] = [UIImage imageWithData:data];
        return;**//沙盒找到第二张照片,返回。**
    }
......
}

5.一开始创建的时候,self.currImageView.frame = CGRectMake(self.width * 2, 0, self.width, self.height);

- (void)setScrollViewContentSize {
    if (_images.count > 1) {
        self.scrollView.contentSize = CGSizeMake(self.width * 5, 0);
        self.scrollView.contentOffset = CGPointMake(self.width * 2, 0);
        self.currImageView.frame = CGRectMake(self.width * 2, 0, self.width, self.height);
        if (_changeMode == ChangeModeFade) {
            _currImageView.frame = CGRectMake(0, 0, self.width, self.height);
            _otherImageView.frame = self.currImageView.frame;
            _otherImageView.alpha = 0;
            [self insertSubview:self.currImageView atIndex:0];
            [self insertSubview:self.otherImageView atIndex:1];
        }
        [self startTimer];
    } else {
        self.scrollView.contentSize = CGSizeZero;
        self.scrollView.contentOffset = CGPointZero;
        self.currImageView.frame = CGRectMake(0, 0, self.width, self.height);
    }
}

6.刷新页面成功了,但主要是currImageView的x为self.width * 2,导致页面无法显示

//防止在滚动过程中重新给imageArray赋值时报错
    if (_currIndex >= _images.count) _currIndex = _images.count - 1;
    self.currImageView.image = _images[_currIndex];
    self.describeLabel.text = _describeArray[_currIndex];
    self.pageControl.numberOfPages = _images.count;
    [self layoutSubviews];

麻烦你确认一下,或者是我reload的时候不应该这样赋值,谢谢!

from xrcarouselview.

codingZero avatar codingZero commented on May 28, 2024

@wyhazq 你的这种赋值方式没错,我刚刚试了下,我这边没有问题,你重新赋值后,如果数组只有一个元素,就会执行self.currImageView.frame = CGRectMake(0, 0, self.width, self.height);,不会出现你说的那种情况。你reload的时候打个断点,看看内部是怎么执行的

from xrcarouselview.

wyhazq avatar wyhazq commented on May 28, 2024

结论:我是作者没有支持cocoapods时下载的版本,忘记更新了,老版本一张图片时没有stopTimer,导致的scrollview的contentOffset.x为2*self.width造成的bug。
过程:谢谢作者提醒,我早上断点调了下,frame是正确的,然后找了好久,终于发现原来是一张图片时没有stopTimer,兴高采烈的去下载demo,重现一下,发觉并没有重现,点进去一看,原来已经修复此bug,瞬间发现是自己懵逼了,原来和作者不在一个频道上......
十分抱歉,以后发现什么bug必须的先更新到最新版本,查看issue才行。添加了pod,现在没事了,感谢提醒,XRCarouselView很好用,赞一个!

from xrcarouselview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.