今天試著寫ios 類似淘寶商品詳情頁面的效果
我用到的第三方庫EGORefreshTableHeaderView下拉刷新的效果還有就是PWLoadMoreTableFooterView上拉加載更多
主要的思路在於UISCrollView兩頁,一頁展示商品概況,另一頁展示商品更多詳情
首先,第一頁的view包含一個UITableView,這個tableView實現PWLoadMoreTableFooterView中的delegate方法,
實現delegate代理方法的時候使用
- (void)scrollViewByPageControlPage:(NSInteger)page { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.50]; [self.backScrollView setContentOffset:CGPointMake(0, (ScreenHeight-navigationHeight-OffsetHeight)*page)]; [UIView commitAnimations]; }
再次,在scrollview的第二頁中加入一個View ,在此view上再創建一個ScrollView,這個scrollView實現EGORefreshTableHeaderView的delegate方法
具體如下:
#pragma mark - #pragma mark EGORefreshTableHeaderDelegate Methods - (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{ [self reloadTableViewDataSource]; [self performSelector:@selector(doneLoadingTableViewDataForIndex) withObject:nil afterDelay:1.0]; } - (void)doneLoadingTableViewDataForIndex { _reloading = NO; [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:lectureScrollView]; [_loadMoreFooterView pwLoadMoreTableDataSourceDidFinishedLoading]; [self scrollViewByPageControlPage:0]; } - (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{ return _reloading; // should return if data source model is reloading } - (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{ return [NSDate date]; // should return date data source was last changed }一下實現EGORefreshTableHeaderView的delegate方法
- (void)doneLoadingTableViewDataForIndex { _reloading = NO; [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:lectureScrollView]; [_loadMoreFooterView pwLoadMoreTableDataSourceDidFinishedLoading]; [self scrollViewByPageControlPage:0]; }