Skip to content

Commit

Permalink
一些残留的问题
Browse files Browse the repository at this point in the history
1.用async+mainQueue替代endRefreshing的0.1s延迟问题
2.完善:圈圈控件根据文字长短变换位置
  • Loading branch information
MJ Lee authored and MJ Lee committed Jun 14, 2016
1 parent 4e7ead8 commit ada9e24
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
2 changes: 1 addition & 1 deletion MJRefresh.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MJRefresh'
s.version = '3.1.4'
s.version = '3.1.5'
s.summary = 'An easy way to use pull-to-refresh'
s.homepage = 'https://github.com/CoderMJLee/MJRefresh'
s.license = 'MIT'
Expand Down
24 changes: 7 additions & 17 deletions MJRefresh/Base/MJRefreshBackFooter.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,19 @@ - (void)setState:(MJRefreshState)state
}
}

#pragma mark - 公共方法
- (void)endRefreshing
{
if ([self.scrollView isKindOfClass:[UICollectionView class]]) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[super endRefreshing];
});
} else {
[super endRefreshing];
}
dispatch_async(dispatch_get_main_queue(), ^{
self.state = MJRefreshStateIdle;
});
}

- (void)noticeNoMoreData
- (void)endRefreshingWithNoMoreData
{
if ([self.scrollView isKindOfClass:[UICollectionView class]]) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[super noticeNoMoreData];
});
} else {
[super noticeNoMoreData];
}
dispatch_async(dispatch_get_main_queue(), ^{
self.state = MJRefreshStateNoMoreData;
});
}

#pragma mark - 私有方法
#pragma mark 获得scrollView的内容 超出 view 的高度
- (CGFloat)heightForContentBreakView
Expand Down
4 changes: 3 additions & 1 deletion MJRefresh/Base/MJRefreshComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ - (void)setState:(MJRefreshState)state
{
_state = state;

[self setNeedsLayout];
dispatch_async(dispatch_get_main_queue(), ^{
[self setNeedsLayout];
});
}

#pragma mark 进入刷新状态
Expand Down
10 changes: 3 additions & 7 deletions MJRefresh/Base/MJRefreshHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,9 @@ - (void)setState:(MJRefreshState)state
#pragma mark - 公共方法
- (void)endRefreshing
{
if ([self.scrollView isKindOfClass:[UICollectionView class]]) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[super endRefreshing];
});
} else {
[super endRefreshing];
}
dispatch_async(dispatch_get_main_queue(), ^{
self.state = MJRefreshStateIdle;
});
}

- (NSDate *)lastUpdatedTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (void)example21
[self.collectionView.mj_header beginRefreshing];

// 上拉刷新
self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
self.collectionView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
// 增加5条假数据
for (int i = 0; i<5; i++) {
[weakSelf.colors addObject:MJRandomColor];
Expand Down

0 comments on commit ada9e24

Please sign in to comment.