Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPageControl is not Displayed

I use the following to display scrollview and pagecontrol

scrollView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 179)];
    pageControl=[[UIPageControl alloc] initWithFrame:CGRectMake(0, 179, 320, 20)];

    scrollView.delegate = self;
    [scrollView setBackgroundColor:[UIColor blackColor]];
    [scrollView setCanCancelContentTouches:NO];
    scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    scrollView.clipsToBounds = YES;
    scrollView.scrollEnabled = YES;
    scrollView.pagingEnabled = YES;

    int index=[[self._parameters objectForKey:@"index"] intValue];
    NSString *imageNamePrefix=[[activeAppIdList objectAtIndex:index] objectForKey:@"AppID"];
    int noOfScreenShot=[[[activeAppIdList objectAtIndex:index] objectForKey:@"NoOfScreenShot"] intValue];

    CGFloat cx = 0;
    for (int j=1;j<=noOfScreenShot ; j++) {
        UIImage *image =[[UIImage alloc] init];
        image= [self loadImage:[[NSString alloc]initWithFormat:@"%@_%d.jpg",imageNamePrefix,j]];

           if (image == nil) {

            NSString *urlString = [[NSString alloc]initWithFormat:@"http://localhost/MoreApp/images/%@_%d.jpg",imageNamePrefix,j];

               NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
            UIImage *temp=[[UIImage alloc]initWithData:imageData] ;

            [self saveImage:temp withName:[[NSString alloc]initWithFormat:@"%@_%d.jpg",imageNamePrefix,j]];

            image = temp;
            [temp release];
            [urlString release];
        }

        UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
        [image release];
        imageView.frame = CGRectMake(cx,0,scrollView.frame.size.width,scrollView.frame.size.height);
                [scrollView addSubview:imageView];
        [imageView release];

        cx += scrollView.frame.size.width;


    }

    NSLog(@"No Of pages..%d",noOfScreenShot);
    pageControl.numberOfPages = noOfScreenShot;
    pageControl.currentPage = 0;
        scrollView.contentSize = CGSizeMake(cx,scrollView.frame.size.height);

    NSLog(@"Width:%f",scrollView.frame.size.width);

    [ refToSelf.instructionView addSubview:scrollView];
    [ refToSelf.instructionView addSubview:pageControl];


    [scrollView release];
    [pageControl release];

scrollview is ok but pagecontroll didn't showed... can help??

like image 805
Rony Avatar asked Jul 20 '10 06:07

Rony


3 Answers

If the page control's and container's background color is the same (by default white) page control won't be visible.

like image 168
srgtuszy Avatar answered Nov 13 '22 11:11

srgtuszy


For anyone who finds this, another silly mistake you can make is to not set the numberOfPages attribute on the UIPageControl, which will also cause it to not display.

like image 26
apb Avatar answered Nov 13 '22 11:11

apb


My mistake was equally annoying - developing with storyboard in 3.5 inch view, and built on 4 inch device on simulator so it was offscreen. Silly!

like image 2
Joel Balmer Avatar answered Nov 13 '22 12:11

Joel Balmer