禁用UIPageControl的点击翻页事件。但是不禁用滑动翻页。如何做到。
如果不这样禁掉的话,点击UIPageControl会发生UIPageControl自己向右走了一页。

解决方案 »

  1.   

    那就自定义UIPageControl,现成的代码,送给你,记得继承UIPageControl,试过了,完美符合你的要求#import "BQCustomPageControl.h"#define circleWidth   10.0
    #define circlePadding 12.5@implementation BQCustomPageControl- (void)layoutSubviews{
        [super layoutSubviews];
        
        //计算圆点间距
        CGFloat marginX = circleWidth + circlePadding;
        
        //计算整个pageControll的宽度
        CGFloat newWidth = (self.subviews.count-1)*marginX + circleWidth;
        
        //设置新frame
        self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, newWidth, self.frame.size.height);
        
        //设置居中
        CGPoint center = self.center;
        center.x = self.superview.center.x;
        self.center = center;
        
        //遍历subview,设置圆点frame
        for (int i=0; i<[self.subviews count]; i++) {
            UIImageView *dot = [self.subviews objectAtIndex:i];
            dot.layer.cornerRadius = circleWidth*0.5;
            if (i == self.currentPage) {
                [dot setFrame:CGRectMake(i * marginX, dot.frame.origin.y, circleWidth, circleWidth)];
            }else {
                [dot setFrame:CGRectMake(i * marginX, dot.frame.origin.y, circleWidth, circleWidth)];
            }
        }
    }@end