diff --git a/PanelTableView/.DS_Store b/PanelTableView/.DS_Store new file mode 100644 index 0000000..f4dd47c Binary files /dev/null and b/PanelTableView/.DS_Store differ diff --git a/PanelTableView/Classes/PanelView.h b/PanelTableView/Classes/PanelView.h index 24d7bf4..fedb658 100644 --- a/PanelTableView/Classes/PanelView.h +++ b/PanelTableView/Classes/PanelView.h @@ -42,6 +42,9 @@ - (CGFloat)panelView:(id)panelView heightForRowAtIndexPath:(PanelIndexPath *)indexPath; - (NSInteger)panelView:(id)panelView numberOfSectionsInPage:(NSInteger)pageNumber; - (NSString*)panelView:(id)panelView titleForHeaderInPage:(NSInteger)pageNumber section:(NSInteger)section; +- (UIView *)panelView:(id)panelView viewForHeaderInPage:(NSInteger)pageNumber section:(NSInteger)section; +- (void)panelView:(id)panelView didScroll:(UIScrollView *)scrollView; +- (CGFloat)panelView:(id)panelView heightForHeaderInSection:(NSInteger)section; @end @interface PanelView : UIView diff --git a/PanelTableView/Classes/PanelView.m b/PanelTableView/Classes/PanelView.m index 50db4fb..b343c80 100644 --- a/PanelTableView/Classes/PanelView.m +++ b/PanelTableView/Classes/PanelView.m @@ -391,4 +391,28 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte return nil; } +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section +{ + if ([self.delegate respondsToSelector:@selector(panelView:viewForHeaderInPage:section:)]) { + return [self.delegate panelView:self viewForHeaderInPage:self.pageNumber section:section]; + } + return nil; +} + +- (void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + if ([self.delegate respondsToSelector:@selector(panelView:didScroll:)]) { + return [self.delegate panelView:self didScroll:scrollView]; + } +} + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section +{ + if ([self.delegate respondsToSelector:@selector(panelView:heightForHeaderInSection:)]) { + return [self.delegate panelView:self heightForHeaderInSection:section]; + } else { + return 0; + } +} + @end diff --git a/PanelTableView/Classes/PanelsViewController.h b/PanelTableView/Classes/PanelsViewController.h index de7f8c1..b9e85a8 100644 --- a/PanelTableView/Classes/PanelsViewController.h +++ b/PanelTableView/Classes/PanelsViewController.h @@ -68,7 +68,9 @@ - (void)pushNextPage; - (void)jumpToPreviousPage; - - (NSInteger)numberOfPanels; +#pragma mark - PYology, Yann +- (void)goToPanel:(NSInteger)index; + @end diff --git a/PanelTableView/Classes/PanelsViewController.m b/PanelTableView/Classes/PanelsViewController.m index dca65ba..9c99a05 100644 --- a/PanelTableView/Classes/PanelsViewController.m +++ b/PanelTableView/Classes/PanelsViewController.m @@ -65,7 +65,7 @@ - (void)loadView [_scrollView setPagingEnabled:YES]; [_scrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; [self.view addSubview:self.scrollView]; - [_scrollView setContentSize:CGSizeMake(([self panelViewSize].width+2*GAP)*[self numberOfPanels],_scrollView.frame.size.height)]; + [_scrollView setContentSize:CGSizeMake(([self panelViewSize].width+2*GAP)*[self numberOfPanels],_scrollView.frame.size.height-frame.origin.y)]; _recycledPages = [NSMutableSet set]; _visiblePages = [NSMutableSet set]; @@ -408,5 +408,11 @@ - (NSString*)panelView:(id)panelView titleForHeaderInPage:(NSInteger)pageNumber return [NSString stringWithFormat:@"Page %i Section %i", pageNumber, section]; } +- (void)goToPanel:(NSInteger)index +{ + self.scrollView.bounds = CGRectMake(index * self.scrollView.bounds.size.width, self.scrollView.bounds.origin.y, self.scrollView.bounds.size.width, self.scrollView.bounds.size.height); + + [self tilePages]; +} @end diff --git a/PanelTableView/PanelTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/PanelTableView/PanelTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..f23e28a --- /dev/null +++ b/PanelTableView/PanelTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/PanelTableView/PanelTableView.xcodeproj/project.xcworkspace/xcuserdata/yann.xcuserdatad/UserInterfaceState.xcuserstate b/PanelTableView/PanelTableView.xcodeproj/project.xcworkspace/xcuserdata/yann.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..7ae53e6 Binary files /dev/null and b/PanelTableView/PanelTableView.xcodeproj/project.xcworkspace/xcuserdata/yann.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/PanelTableView/PanelTableView.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/PanelTableView.xcscheme b/PanelTableView/PanelTableView.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/PanelTableView.xcscheme new file mode 100644 index 0000000..4ef8ac1 --- /dev/null +++ b/PanelTableView/PanelTableView.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/PanelTableView.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PanelTableView/PanelTableView.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/xcschememanagement.plist b/PanelTableView/PanelTableView.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..0d31fa5 --- /dev/null +++ b/PanelTableView/PanelTableView.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + PanelTableView.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 1D6058900D05DD3D006BFB54 + + primary + + + + + diff --git a/README.md b/README.md index 87e5953..9c4dff9 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,5 @@ Contact [honcheng.com](http://honcheng.com) [@honcheng](http://twitter.com/honcheng) +![](http://www.cocoacontrols.com/analytics/honcheng/paneltableview.png) + diff --git a/sample project/SampleApp/.DS_Store b/sample project/SampleApp/.DS_Store new file mode 100644 index 0000000..ead6662 Binary files /dev/null and b/sample project/SampleApp/.DS_Store differ diff --git a/sample project/SampleApp/SampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/sample project/SampleApp/SampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..2c451d7 --- /dev/null +++ b/sample project/SampleApp/SampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/sample project/SampleApp/SampleApp.xcodeproj/project.xcworkspace/xcuserdata/yann.xcuserdatad/UserInterfaceState.xcuserstate b/sample project/SampleApp/SampleApp.xcodeproj/project.xcworkspace/xcuserdata/yann.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..ecd910f Binary files /dev/null and b/sample project/SampleApp/SampleApp.xcodeproj/project.xcworkspace/xcuserdata/yann.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/sample project/SampleApp/SampleApp.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/SampleApp.xcscheme b/sample project/SampleApp/SampleApp.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/SampleApp.xcscheme new file mode 100644 index 0000000..b9fa974 --- /dev/null +++ b/sample project/SampleApp/SampleApp.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/SampleApp.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample project/SampleApp/SampleApp.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/xcschememanagement.plist b/sample project/SampleApp/SampleApp.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..2818fed --- /dev/null +++ b/sample project/SampleApp/SampleApp.xcodeproj/xcuserdata/yann.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + SampleApp.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 1D6058900D05DD3D006BFB54 + + primary + + + + +