-1

I want to scroll the line (uiview - Hieght=1) between the button And i had put the button in container view of pageviewcontroller.Pageviewcontroller is starting from bottom of the buttons .I want the line to move when i scroll pageviewcontrollers subviews. The Image as shown below... enter image description here

So this line white line I want to move when I scroll page 1 to 2 then 2 - 1 How can i do this Please help.... As I have to use pageviewcontroller

Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
Mohammed Hussain
  • 176
  • 2
  • 13

2 Answers2

1

you can do this in with help of UIScrollView , in here no need of UIpageViewController

take the delegate methods of

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
- (void)scrollViewDidScroll:(UIScrollView *)sender;

Step-1

create the one scrollView like self.tblScroll

//It call end of scroll

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
if (scrollView != MovemylineinBlack && scrollView != MovemylineinRed)
{
    int x=fmod(scrollView.contentOffset.x, self.tblScroll.frame.size.width);
    if (x <= self.tblScroll.frame.size.width/2 )
    {
        [scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x-x, scrollView.contentOffset.y) animated:YES];
    }
    else
    {
        [scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x+self.tblScroll.frame.size.width-x, scrollView.contentOffset.y) animated:YES];
    }
   }
}

Step-2

// it s call your scroll is closusre

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate: (BOOL)decelerate
{
if (scrollView != MovemylineinBlack && scrollView != MovemylineinRed)
{
    int x=fmod(scrollView.contentOffset.x, self.tblScroll.frame.size.width);
    if (x <= self.tblScroll.frame.size.width/2 )
    {
        [scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x-x, scrollView.contentOffset.y) animated:YES];
    }
    else
    {
        [scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x+self.tblScroll.frame.size.width-x, scrollView.contentOffset.y) animated:YES];
    }
   }
 }

Step-3

// Imeplement the every drag of move capture method

- (void)scrollViewDidScroll:(UIScrollView *)sender
{
  if (self.tblScroll.contentOffset.x<KAPPDeviceWidth/2) // KAPPDeviceWidth--> this is your view Width
{
    self.viewSubBack.frame=CGRectMake(self.tblScroll.contentOffset.x, 106, 160, 5); // viewSubBack --> is your white line
}
else
{
    self.viewSubBack.frame=CGRectMake((KAPPDeviceWidth/2)+1, 106, 160, 5);
}
}
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
0

This project will let you integrate this need https://github.com/hightower/HTHorizontalSelectionList

Rajesh
  • 10,318
  • 16
  • 44
  • 64
  • Since there are sourcecode available you may use it straight away.. Its one of the great implementation – Rajesh Feb 09 '16 at 15:17
  • But When I scroll between the pages in pageviewcontroller did the line will scroll between the buttons accordingly...?? – Mohammed Hussain Feb 09 '16 at 15:19
  • Yeah with - (void)setSelectedButtonIndex:(NSInteger)selectedButtonIndex animated:(BOOL)animated; it will happen – Rajesh Feb 10 '16 at 03:14