Open ieliwb opened 4 years ago
@gsdios
我也是这个情况 大家有解决的吗?
I have the same problem.
一样,正在研究解决方法
一样有这个问题有大佬解决了吗
@gsdios 作者还会更新这个库吗
需要自定义pageControl,因为内部UI结构已经更改了,API都更新了
问题解决:
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);
}
楼上的方法可以解决,不过需要在 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; }
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>>"
问题解决: 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); }]; } }
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.
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.
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!
费那劲干嘛?
if (@available(iOS 14.0, *)) {
x = 0;
size.width = self.sd_width;
}
费那劲干嘛?
if (@available(iOS 14.0, *)) { x = 0; size.width = self.sd_width; }
如图位置
效果图,左边之前
Thanks,the code solve the problem,too.👌
if (@available(iOS 14.0, *)) {
x = 0;
size.width = self.frame.size.width;
}
费那劲干嘛?
if (@available(iOS 14.0, *)) { x = 0; size.width = self.sd_width; }
如图位置
效果图,左边之前
棒👍
这样改了,右边那个属性就没作用了呀
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;
}
}
}
mark
已经修复,并发布1.82版本
已经修复,并发布1.82版本
👍
RT,pageDot 不见了