Open npzlxph0415 opened 4 years ago
(UIView *)thumbView {
if (!_thumbView && self.subviews.count > 2) { _thumbView = self.subviews[2]; } else { UIView *view = self.subviews[0]; _thumbView = view.subviews[2]; } return _thumbView; }
- (UIView )thumbView { if (!_thumbView && self.subviews.count > 2) { _thumbView = self.subviews[2]; } else { UIView view = self.subviews[0]; _thumbView = view.subviews[2]; } return _thumbView; }
实际运行下你会发现是崩溃的
(UIView *)thumbView {
if (@available(iOS 14.0, *)) {
if (!_thumbView && self.subviews.count > 2) {
[self layoutSubviews];
UIView *view = self.subviews[2];
if (view.subviews.count > 2) {
_thumbView = view.subviews[2];
}
}
}else {
if (!_thumbView && self.subviews.count > 2) {
_thumbView = self.subviews[2];
}
}
return _thumbView; }
这样可以解决
(UIView )thumbView { if (@available(iOS 14.0, )) {
if (!_thumbView && self.subviews.count > 2) { [self layoutSubviews]; UIView *view = self.subviews[2]; if (view.subviews.count > 2) { _thumbView = view.subviews[2]; } }
}else {
if (!_thumbView && self.subviews.count > 2) { _thumbView = self.subviews[2]; }
} return _thumbView; }
这样可以解决
ios15以上又不行了,不过我找到更好的方法
(UIView )thumbView { if (@available(iOS 14.0, )) {
if (!_thumbView && self.subviews.count > 2) { [self layoutSubviews]; UIView *view = self.subviews[2]; if (view.subviews.count > 2) { _thumbView = view.subviews[2]; } }
}else {
if (!_thumbView && self.subviews.count > 2) { _thumbView = self.subviews[2]; }
} return _thumbView; }
什么办法
同上面问题