[下载地址]https://git.oschina.net/mrj_mrj/pagesFilp.git
实现原理:
用一个UIScrollow 作为最底下的试图,上面加载两个可以滚动的试图,比如UITableView,UIScrollow,UIWebView,这里用的是UITableView和UIWebView.
效果图:
关键代码部分:
- 1:初始化布局
<p>UIScrollView</p><pre><code>
-
(UIScrollView *)baseScrollow
{if (_baseScrollow == nil)
{
_baseScrollow = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, _screenWide, _screenHeight)];
_baseScrollow.contentSize = CGSizeMake(_screenWide, _screenHeight * 2);
//设置分页效果
_baseScrollow.pagingEnabled = YES;
//禁用滚动
_baseScrollow.scrollEnabled = NO;
}return _baseScrollow;
}
</code></pre>
<p>UITableView</p><pre><code>
-
(UITableView *)topTableView
{if (!_topTableView) {
_topTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, _screenWide, _screenHeight) style:UITableViewStylePlain];
[_topTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
_topTableView.delegate = self;
_topTableView.dataSource = self;
}return _topTableView;
}
</code></pre>
<p>UIWebView</p><pre><code>
-
(UIWebView *)webView
{if (!_webView) {
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, _screenHeight, _screenWide, _screenHeight)];
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]]];
}return _webView;
}
</code></pre>
<p>滑动效果</p><pre><code>
self.topTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
[UIView animateWithDuration:1 animations:^{
self.baseScrollow.contentOffset = CGPointMake(0, _screenHeight);
} completion:^(BOOL finished) {
[self.topTableView.mj_footer endRefreshing];
}];
}];
self.webView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
[UIView animateWithDuration:1 animations:^{
self.baseScrollow.contentOffset = CGPointMake(0, 0);
} completion:^(BOOL finished) {
[self.webView.scrollView.mj_header endRefreshing];
}];
}];
}
</code></pre>