Reputation: 11193
i've added a pageControl to the titleView using the interface builder. The problem is that it is not centered at all. I could actually just do a lot of white spaces after the leftBarButton text, but it is not ideal. What would be the solution?
Upvotes: 0
Views: 617
Reputation: 31
I came across this post while looking for an answer for the exact problem. I ended up solving it by adding UIPageControl
inside an UIView
and set the proper constraints to center itself inside the UIView
. You can do this in storyboard easily and add this UIView
to titleView. Hope this helps.
Upvotes: 1
Reputation: 104082
The title view is centered automatically (if it's possible), so it's probably being pushed to the left by the right bar button item. You should add a background color to your title view for debugging purposes, so you can see if this is true. If that's the problem, you need to make your titleView smaller so it doesn't run into either button.
The other possibility (which you could see if you had a background color) is that the page control is not centered in the titleView. If that's the problem, you need to add a centerX constraint to the page control.
Upvotes: 0
Reputation: 1884
Instead of adding your pagecontroller from Storyboard try doing this
pageControl = [[UIPageControl alloc] init];
pageControl.frame = CGRectMake(x, y, xx, yy);
pageControl.numberOfPages = 2;
pageControl.currentPage = 0;
self.navigationItem.titleView = pageControl;
Upvotes: 1