سؤال

Im generating an UIPageControl to be related with a scroll view for a welcome view but the pagecontrol is not showing on screen, this is my code:

-(void)viewDidLoad{
[super viewDidLoad];

UIScrollView *scrollview = [[UIScrollView alloc]initWithFrame:self.view.bounds];
    scrollview.delegate = self;
    UIPageControl *pagecontrol = [[UIPageControl alloc]initWithFrame:CGRectMake(141, 511, 39, 37)];
pagecontrol.numberOfPages = 3;
    pagecontrol.currentPageIndicatorTintColor = [UIColor GreenCMTColor];
    pagecontrol.pageIndicatorTintColor = [UIColor grayColor];

[self.navigationController.view addSubview:pagecontrol];
    [self.navigationController.view addSubview:scrollview];

}

I need help to find the problem, inside the scrollview I have a view where I display different imageViews.

هل كانت مفيدة؟

المحلول

I think you should not add subview into navigationController.view because this subview will be follow navigation controller instead of the view which you want to add it. And in this case, you can't see UIPagecontroller because the crollview will be overlap the Pagcontroller. You must add scrollview first and pagecontroller later:

[self.navigationController.view addSubview:scrollview];
[self.navigationController.view addSubview:pagecontrol];

نصائح أخرى

I think you're adding the subviews in the wrong way, try changing:

[self.navigationController.view addSubview:pagecontrol];
[self.navigationController.view addSubview:scrollview];

By:

[self.view addSubview:pagecontrol];
[self.view addSubview:scrollview];

Let me know if that fix the issue.

Thanks!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top