I'm trying to centralize a UIPageControl
in portrait and landscape modes, but it isn't working, the x changes after device rotation.
@interface DetailViewController : UIViewController<UIScrollViewDelegate>
{
UIPageControl *pageControl;
}
- (void)viewDidLoad
{
pageControl = [[UIPageControl alloc] init] ;
[self renderMyView];
[self.view addSubview:pageControl];
}
- (void)renderMyView
{
if(isPortrait)
{
pageControl.frame = CGRectMake(200, 976, 0, 0);
} else {
pageControl.frame = CGRectMake(200, 720, 0, 0);
}
}
The renderMyView
is executed on didLoad
and didRotate
.
At first time viewDidLoad
works well in portrait and landscape, but if I rotate the device the pageControl
appears in a different x != 200
.
I've also tried pageControl.center
, but it didn't work.
How can I keep it centralized?