贴代码
- 添加监听程序回到前台通知
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(zse_applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification
object:nil];
- 用NSUserDefaults 存了个时间戳 判断是否距离上次过了 xx时间 过了的话刷新
就这几行代码就会发生bug 下拉刷新动画不会执行,也不会进行请求接口。
-(void)zse_applicationDidBecomeActive{
NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
NSInteger value = [def integerForKey:@"zse_applicationDidBecomeActive_time"];
if (value < time(0)) {
[self.collectionView.mj_header beginRefreshing];
[def setInteger:time(0) forKey:@"zse_applicationDidBecomeActive_time"];
}
}
网友评论