TanguyAladenise / TAPageControl

A versatile and easily customizable page control for iOS.
MIT License
431 stars 83 forks source link

Add support for auto-layout #4

Open walteryaron opened 9 years ago

jiteshsharma43 commented 9 years ago

In case of auto layout..dot views are not aligned center in the View. they are start with right alignment.

TanguyAladenise commented 9 years ago

I have found a fix for the center problem with auto layout but need more time to test it out on non auto layout project. I will try to update as soon as possible

mohreda commented 8 years ago

i've same problem with auto layout; if i put any constrain there's a problem on scrolling; all image shift to right

floriangbh commented 8 years ago

Same problem here, can't make center alignment. Any solution ? :-)

mariovillamizar commented 7 years ago

I found a solution. Configure your page control into viewDidLayoutSubviews method

immago commented 6 years ago

If you can not able configure a component in viewDidLayoutSubviews (for example, it's subview in custom view class), as mentioned above, there are another solution:

-(void)myCustomInitMethod
    // TAPageControl don't work correct with autolayout, observe frame
    [self.pageControl addObserver:self forKeyPath:@"bounds" options:0 context:nil];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    if (object == self.pageControl && [keyPath isEqualToString:@"bounds"]) {
        // Set number of pages to trigger private update method
        self.pageControl.numberOfPages = self.pageControl.numberOfPages;
    }
}

-(void)dealloc{
    [self.pageControl removeObserver:self forKeyPath:@"bounds"];
}