gsdios / SDCycleScrollView

Autoscroll Banner. 无限循环图片、文字轮播器。
MIT License
6.18k stars 1.5k forks source link

[DONE] iOS 14 小点点消失了,有人是这样吗? #629

Open ieliwb opened 3 years ago

ieliwb commented 3 years ago

RT,pageDot 不见了

ieliwb commented 3 years ago

@gsdios

LucaLiu commented 3 years ago

我也是这个情况 大家有解决的吗?

gongbojie commented 3 years ago

I have the same problem.

nijino commented 3 years ago

一样,正在研究解决方法

PZXforXcode commented 3 years ago

一样有这个问题有大佬解决了吗

PZXforXcode commented 3 years ago

@gsdios 作者还会更新这个库吗

Mamakou commented 3 years ago

需要自定义pageControl,因为内部UI结构已经更改了,API都更新了

OyesOnoOmg commented 3 years ago

问题解决: SDCycleScrollView.m中 全局搜 self.pageControl.frame = CGRectMake(x, y, size.width, size.height); 替换为
if (@available(iOS 14.0, )) { [self.pageControl mas_makeConstraints:^(MASConstraintMaker make) { make.centerX.equalTo(self); make.bottom.offset(-10); make.height.offset(self.pageControlDotSize.height); }]; }else{ self.pageControl.frame = CGRectMake(x, y, size.width, size.height); }

nijino commented 3 years ago

楼上的方法可以解决,不过需要在 SDCycleScrollView 中引入 Masonry 库,另外适配的代码在 SDCycleScrollView.m 的 525 行,需要这么写: if (@available(iOS 14.0, )) { [self.pageControl mas_makeConstraints:^(MASConstraintMaker make) { make.centerX.equalTo(self); make.bottom.offset(-10); make.height.offset(self.pageControlDotSize.height); }]; } else { CGRect pageControlFrame = CGRectMake(x, y, size.width, size.height); pageControlFrame.origin.y -= self.pageControlBottomOffset; pageControlFrame.origin.x -= self.pageControlRightOffset; self.pageControl.frame = pageControlFrame; }

gongbojie commented 3 years ago

It works! But my code is:

    if (@available(iOS 14.0, *)) {
        [self addSubview:self.pageControl];
        [self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.bottom.offset(-10);
            make.height.offset(self.pageControlDotSize.height);
        }];
    } else {
        CGRect pageControlFrame = CGRectMake(x, y, size.width, size.height);
        pageControlFrame.origin.y -= self.pageControlBottomOffset;
        pageControlFrame.origin.x -= self.pageControlRightOffset;
        self.pageControl.frame = pageControlFrame;
    }

If i haven't write this line:[self addSubview:self.pageControl];, the app will crash.

Thread 1: "couldn't find a common superview for <UIPageControl: 0x11fe1e230; frame = (0 0; 0 0); autoresize = W; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x2832ee460>; layer = <CALayer: 0x283c4d6a0>> and <SDCycleScrollView: 0x11fe30450; frame = (0 0; 345 80); clipsToBounds = YES; layer = <CALayer: 0x283c4e180>>"

huangfangkai commented 3 years ago

问题解决: SDCycleScrollView.m中 全局搜 self.pageControl.frame = CGRectMake(x, y, size.width, size.height); 替换为 if ([self.pageControl isKindOfClass:[TAPageControl class]]) { CGRect pageControlFrame = CGRectMake(x, y, size.width, size.height); pageControlFrame.origin.y -= self.pageControlBottomOffset; pageControlFrame.origin.x -= self.pageControlRightOffset; self.pageControl.frame = pageControlFrame; }else{ if (_pageControlAliment == SDCycleScrollViewPageContolAlimentRight) { [self.pageControl mas_makeConstraints:^(MASConstraintMaker make) { if (@available(iOS 14.0, )) { make.right.equalTo(self).offset(25); }else{ make.right.equalTo(self).offset(-_pageControlRightOffset); } make.bottom.offset(-self.pageControlBottomOffset); make.height.offset(self.pageControlDotSize.height); }]; }else{ [self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.bottom.offset(-self.pageControlBottomOffset); make.height.offset(self.pageControlDotSize.height); }]; } }

nijino commented 3 years ago

It works! But my code is:

    if (@available(iOS 14.0, *)) {
        [self addSubview:self.pageControl];
        [self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.bottom.offset(-10);
            make.height.offset(self.pageControlDotSize.height);
        }];
    } else {
        CGRect pageControlFrame = CGRectMake(x, y, size.width, size.height);
        pageControlFrame.origin.y -= self.pageControlBottomOffset;
        pageControlFrame.origin.x -= self.pageControlRightOffset;
        self.pageControl.frame = pageControlFrame;
    }

If i haven't write this line:[self addSubview:self.pageControl];, the app will crash.

Thread 1: "couldn't find a common superview for <UIPageControl: 0x11fe1e230; frame = (0 0; 0 0); autoresize = W; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x2832ee460>; layer = <CALayer: 0x283c4d6a0>> and <SDCycleScrollView: 0x11fe30450; frame = (0 0; 345 80); clipsToBounds = YES; layer = <CALayer: 0x283c4e180>>"

I didn't encounter this situation,but I saw the pagecontrol ivar has been added in its superview at line 401 or 414 in SDCycleScrollView.m file.

gongbojie commented 3 years ago

It works! But my code is:

    if (@available(iOS 14.0, *)) {
        [self addSubview:self.pageControl];
        [self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.bottom.offset(-10);
            make.height.offset(self.pageControlDotSize.height);
        }];
    } else {
        CGRect pageControlFrame = CGRectMake(x, y, size.width, size.height);
        pageControlFrame.origin.y -= self.pageControlBottomOffset;
        pageControlFrame.origin.x -= self.pageControlRightOffset;
        self.pageControl.frame = pageControlFrame;
    }

If i haven't write this line:[self addSubview:self.pageControl];, the app will crash.

Thread 1: "couldn't find a common superview for <UIPageControl: 0x11fe1e230; frame = (0 0; 0 0); autoresize = W; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x2832ee460>; layer = <CALayer: 0x283c4d6a0>> and <SDCycleScrollView: 0x11fe30450; frame = (0 0; 345 80); clipsToBounds = YES; layer = <CALayer: 0x283c4e180>>"

I didn't encounter this situation,but I saw the pagecontrol ivar has been added in its superview at line 401 or 414 in SDCycleScrollView.m file.

Thanks,I notice that.I find this crash because of Masonry.I know that set the Auto Layout before the pageControl(subView) add to the superview(SDCycleScrollView). I track line 401 and line 414 pageControl's address is the same as self.pageControl.But if i not write [self addSubview:self.pageControl];again.App will crush because of that reason.

oymuzi commented 3 years ago

I think you can find these codes in SDCycleScrollView.m version 1.80

       CGRect pageControlFrame = CGRectMake(x, y, size.width, size.height);
        pageControlFrame.origin.y -= self.pageControlBottomOffset;
        pageControlFrame.origin.x -= self.pageControlRightOffset;
        self.pageControl.frame = pageControlFrame;

then replace that:

    if (@available(iOS 14.0, *)) {
        self.pageControl.translatesAutoresizingMaskIntoConstraints = NO;
        [[self.pageControl.centerXAnchor constraintEqualToAnchor:self.centerXAnchor] setActive:YES];
        [[self.pageControl.bottomAnchor constraintEqualToAnchor:self.bottomAnchor constant:-10] setActive:YES];
        [[self.pageControl.heightAnchor constraintEqualToConstant:self.pageControlDotSize.height] setActive:YES];
    } else {
        CGRect pageControlFrame = CGRectMake(x, y, size.width, size.height);
        pageControlFrame.origin.y -= self.pageControlBottomOffset;
        pageControlFrame.origin.x -= self.pageControlRightOffset;
        self.pageControl.frame = pageControlFrame;
    }

it works!

douxindong commented 3 years ago

费那劲干嘛?

if (@available(iOS 14.0, *)) {
    x = 0;
    size.width = self.sd_width;
}

如图位置

效果图,左边:之前;右边:改之后

gongbojie commented 3 years ago

费那劲干嘛?

if (@available(iOS 14.0, *)) {
    x = 0;
    size.width = self.sd_width;
}

如图位置

image

效果图,左边之前

image

Thanks,the code solve the problem,too.👌

if (@available(iOS 14.0, *)) {
        x = 0;
        size.width = self.frame.size.width;
}
Gaozn commented 3 years ago

费那劲干嘛?

if (@available(iOS 14.0, *)) {
    x = 0;
    size.width = self.sd_width;
}

如图位置

image

效果图,左边之前

image

棒👍

huangfangkai commented 3 years ago

这样改了,右边那个属性就没作用了呀

cywd commented 3 years ago
    CGSize size = CGSizeZero;
    if ([self.pageControl isKindOfClass:[TAPageControl class]]) {
        TAPageControl *pageControl = (TAPageControl *)_pageControl;
        if (!(self.pageDotImage && self.currentPageDotImage && CGSizeEqualToSize(kCycleScrollViewInitialPageControlDotSize, self.pageControlDotSize))) {
            pageControl.dotSize = self.pageControlDotSize;
        }
        size = [pageControl sizeForNumberOfPages:self.imagePathsGroup.count];
    } else {
        size = CGSizeMake(self.imagePathsGroup.count * self.pageControlDotSize.width * 1.5, self.pageControlDotSize.height);

        // add code
        if (@available(iOS 14.0, *)) {
            if ([self.pageControl isKindOfClass:[UIPageControl class]]) {
                UIPageControl *pageControl = (UIPageControl *)_pageControl;
                size.width = [pageControl sizeForNumberOfPages:self.imagePathsGroup.count].width;
            }
        }
    }
Free-am commented 3 years ago

mark

gsdios commented 3 years ago

已经修复,并发布1.82版本

douxindong commented 3 years ago

已经修复,并发布1.82版本

👍