Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPageControl not calling selector on valueChanged

I am attempting to use a UIPageControl for the first time and I can't seem to get it to call a function on UIControlEventValueChanged. Am I missing something here? I even tried a storyboard implementation but same broken results. I tried UIControlEventTouchUpInside and other actions as well. None are calling the changePage: function below.

In the .h:

@property (nonatomic, retain) UIPageControl *introPageControl;
-(IBAction)changePage:(id)sender;

In the .m:

@synthesize introPageControl;

- (void)viewDidLoad {
    [super viewDidLoad];
    self.introPageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0,208,self.view.frame.size.width,36)];
    self.introPageControl.numberOfPages = 4;
    self.introPageControl.currentPage = 0;
    [self.introPageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:self.introPageControl];
}

-(IBAction)changePage:(id)sender {
    // NEVER GETS CALLED :(
}
like image 342
AddisDev Avatar asked Feb 16 '23 19:02

AddisDev


1 Answers

The UIControlEventValueChanged is only called when the UIPageControl view object was tapped.

like image 81
MrBr Avatar answered Feb 26 '23 04:02

MrBr