貼代碼
- 添加監(jiān)聽程序回到前臺通知
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(zse_applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification
object:nil];
- 用NSUserDefaults 存了個時間戳 判斷是否距離上次過了 xx時間 過了的話刷新
就這幾行代碼就會發(fā)生bug 下拉刷新動畫不會執(zhí)行荞下,也不會進行請求接口器净。
-(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"];
}
}