ishkawa / ISColumnsController

paginated container view controller.
106 stars 19 forks source link

How to animate the paging on external events #8

Open Quamber opened 10 years ago

Quamber commented 10 years ago

1st of all. Its a great repository indeed however I am going to add some tabs in the main window and i want to shift pages from those tabs how can i do that.?

ishkawa commented 10 years ago

This library does not have the interface to set current page programmatically, but you can set scrollView.contentOffset and pageControl.currentPage by following code.

NSInteger page = 1;
CGPoint contentOffset = CGPointMake(self.scrollView.frame.size.width * page, 0.f);
[self.scrollView setContentOffset:contentOffset animated:YES];
[self.pageControl setCurrentPage:page];

If you placed columns controller in UINavigationController, columnsController.edgesForExtendedLayout should be UIRectEdgeNone.

paresh-navadiya commented 9 years ago

Great work. Working perfectly Add method like this in controller

  -(void)moveToPage:(NSInteger)page
 {
      if (page <= [self.viewControllers count]-1) 
      {
          CGPoint contentOffset = CGPointMake(self.scrollView.frame.size.width * page, 0.f);
          [self.scrollView setContentOffset:contentOffset animated:YES];
          [self.pageControl setCurrentPage:page];
     }
 }