Reputation: 51
// Init Page Control
UIPageControl *pageControl = [[UIPageControl alloc] init];
pageControl.frame = CGRectMake(110,5,100,100);
pageControl.numberOfPages = 2;
pageControl.currentPage = 0;
[self.view addSubview:pageControl];
I'm trying to create UIPageControl programmatically. I created new view based app. In which, i have written this code in ViewControllers viewDidLoad, but its not creating page control. Because of [self.view addSubview:pageControl]; , its getting in infinite loop when application starts. why is it doing so? Is there any other option for this?
Upvotes: 0
Views: 378
Reputation: 90117
move your code from - (void)loadView
to - (void)viewDidLoad
.
Upvotes: 1
Reputation:
I did exactly the same thing and it works for me. You can download my sample application here
Upvotes: 0