Skip to content

Commit

Permalink
解决标题频繁变动时可能崩溃
Browse files Browse the repository at this point in the history
  • Loading branch information
谢兴达 committed Apr 2, 2021
1 parent 2b3223f commit f87714b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion XDPagesView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
# summary should be tweet-length, and the description more in depth.
#
s.name = "XDPagesView"
s.version = "2.1.8"
s.version = "2.1.9"
s.summary = "多控制器列表"
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
Expand Down
10 changes: 6 additions & 4 deletions XDPagesView/XDPagesCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ - (void)setKVOForCurrentPage:(NSInteger)currentPage {

[self clearKVO];

for (UIScrollView *child in [self.pagesCache scrollViewsForTitle:self.pagesCache.titles[currentPage]]) {
[child addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:nil];
NSArray<UIScrollView *>* childs = [self.pagesCache scrollViewsForTitle:self.pagesCache.titles[currentPage]];
if (childs && childs.count) {
for (UIScrollView *child in childs) {
[child addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:nil];
}
[self.pagesCache.kvoTitles addObject:self.pagesCache.titles[currentPage]];
}

[self.pagesCache.kvoTitles addObject:self.pagesCache.titles[currentPage]];
}

// 配置所有标题
Expand Down

0 comments on commit f87714b

Please sign in to comment.