发现 QQ ,微信等在 Push 进 好友动态、朋友圈 这些页面的时候,总能保留在上一次进入时候最后浏览到的位置。这是如何实现的呢?
PHPz2017-04-18 09:20:36
You only need to have a strong reference to the viewController
@property (nonatomic, strong) FooViewController *viewController;
...
- (void)push {
if (!_viewController) {
_viewController = [[FooViewController alloc] init];
}
[self.navigationController pushViewController:_viewController animated:YES];
}
In this way, after popping, the viewController still has a strong reference pointing to it and will not be cleared. The next time you push, you will still push to the viewController
PHP中文网2017-04-18 09:20:36
The simplest thing is to make it a singleton. There is only one instance in the entire app life cycle. Create it once during initialization, and use it the rest of the time.
大家讲道理2017-04-18 09:20:36
This is time limited, right? If you push to enter the page again in a short time, you will stay on the pop-out interface. You only need to judge the time difference between the time of exit and the time of re-entering. If the time difference is less than the time difference, the interface will pop up. If the time difference is greater than the time difference, the interface will be refreshed.
PHP中文网2017-04-18 09:20:36
There is only one thing like Moments in the APP, I think it is better to make it a singleton. After looking at it, when the network is disconnected, it shows that it is loading when I pull it up. When I go back and go back in, it still shows that it is loading. It feels like it is not released.
And the data is also cached. After disconnecting from the Internet, killing the APP, and re-entering, the data refreshed before in the circle of friends can be seen