Note that there are some explanatory texts on larger screens.

plurals
  1. POSubclass of UIPageControl refresh only after uiscrollview move, not before
    primarykey
    data
    text
    <p>the problem I've met today is with my subclass of <code>UIPageControl</code>. When I initialize it, the frame (specifically the origin) and image of dots stays default, which is the problem, since I want it to change right after initialization. However, when I move with scrollView (as in "touch and move") after initialization, they (the dots) somehow jump to the right position with correct images.</p> <p>What could be the problem?</p> <p>Code:</p> <p>CustomPageControl.m</p> <pre><code>- (id) initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; activeImage = [UIImage imageNamed:@"doton.png"]; inactiveImage = [UIImage imageNamed:@"dotoff.png"]; return self; } - (void) updateDots { for (int i = 0; i &lt; [self.subviews count]; i++) { UIImageView *dot = [self.subviews objectAtIndex:i]; if (i == self.currentPage) dot.image = activeImage; else dot.image = inactiveImage; [dot setFrame:CGRectMake(i * 13.5, 1.5, 17, 17)]; } } - (void)setCurrentPage:(NSInteger)currentPage { [super setCurrentPage:currentPage]; [self updateDots]; } @end </code></pre> <p>ChoosingView.m - init part</p> <pre><code>scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 160, 300)]; [scrollView setBackgroundColor:[UIColor clearColor]]; [scrollView setDelaysContentTouches:NO]; [scrollView setCanCancelContentTouches:YES]; [scrollView setClipsToBounds:NO]; [scrollView setScrollEnabled:YES]; [scrollView setPagingEnabled:YES]; [scrollView setShowsHorizontalScrollIndicator:NO]; [scrollView setShowsVerticalScrollIndicator:NO]; pageControl = [[CustomPageControl alloc] initWithFrame:CGRectMake(200, 300, 80, 20)]; [pageControl setBackgroundColor:[UIColor clearColor]]; pageControl.numberOfPages = 6; [pageControl setCurrentPage:0]; </code></pre> <p>the last line is when I would expect the <code>UIPageControl</code> to refresh, however that does not happen.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload