1

I am using UIPageControl and UISwipeGestureRecognizer to switch between 2 view controllers of my application. I have modified this tutorial without using scroll view.

I have 2 issues:

1) Using the swipe gesture is changing the view controllers/pages but not the dots indicating the current page. I have tried

if (self.pageControl.currentPage == 0) {
 self.pageControl.currentPage = 1 
}

but I am not sure why it does not work. I have the outlet available

@property (strong, nonatomic) IBOutlet UIPageControl *pageControl;

2) I am using - (IBAction)changePage:(id)sender for changing the page. I would like to know how to change to a page on clicking on a certain dot. I mean to say that on clicking on dot 1, I should go to the first view controller and on clicking on dot 2, I should navigate to the second view controller.

Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
Dinesh
  • 2,194
  • 3
  • 30
  • 52
  • any suggestion? ideas are welcome... – Dinesh Jan 18 '14 at 16:37
  • Is the `pageControl` outlet `nil`? Tapping on dots will be hard (they are too small, and not an easy to calculate position). – Wain Jan 22 '14 at 16:39
  • I just did like this `pageControl = [[UIPageControl alloc] init];` When I do `NSLog(@"pageControl = %@",pageControl);`, I get `pageControl = >` – Dinesh Jan 22 '14 at 16:44
  • I figured that out now - I was doing `pageControl = [[UIPageControl alloc] init];` That was why current page was not working. Now it works. But could you guide me as to how to change the page on clicking a particular dot - it might not be so easy but I would like to try it. – Dinesh Jan 22 '14 at 16:50
  • You need to know where the dots are and add buttons over them or tap gestures. I don't know how to work out where the dots are - there isn't a public API for that. And from a user point of view, the dots are too small to tap. You shouldn't do it. But feel free to add buttons / gestures to either end of the control - if they are a normal size... – Wain Jan 22 '14 at 17:08
  • Could you explain it with reference to http://stackoverflow.com/questions/21355809/ios-uibutton-on-uipagecontrol-not-working. Also, you might want to post your answer to this question. – Dinesh Jan 26 '14 at 17:16
  • I think - matbe you could post what you said as an answer – Dinesh Jan 30 '14 at 20:00

1 Answers1

0

You need to know where the dots are and add buttons over them or tap gestures. I don't know how to work out where the dots are - there isn't a public API for that. And from a user point of view, the dots are too small to tap. You shouldn't do it. But feel free to add buttons / gestures to either end of the control - if they are a normal size...

Wain
  • 118,658
  • 15
  • 128
  • 151