Question

I'm currently using swipe gestures to switch between view controllers and I'm wondering if I can implement a uipagecontrol on each view controller without using a uiscrollview.

Here is how I'm going from one view controller to another:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.title = @"Home";

    UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithTitle:@"\u2699" style:UIBarButtonItemStyleBordered target:self action:@selector(settingsButtonPressed:)];
    [settingsButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:24], UITextAttributeFont,nil] forState:UIControlStateNormal];
    self.navigationItem.leftBarButtonItem = settingsButton;

    UIBarButtonItem *systemAction = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showMenu)];
    self.navigationItem.rightBarButtonItem = systemAction;

    UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeft:)];
    swipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
    [self.view addGestureRecognizer:swipeRecognizer];
}

- (IBAction)swipeLeft:(UIGestureRecognizer *)sender
{
    HomeTwo *homeTwo = [[HomeTwo alloc]initWithNibName:@"HomeTwo" bundle:nil];
    homeTwo.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self.navigationController pushViewController:homeTwo animated:YES];
}
Was it helpful?

Solution

UIPageControl is just a view so you can certainly add one to each view controllers view and then set the current page to an appropriate value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top