我第一次尝试使用 UIPageControl
,但是似乎无法在 UIControlEventValueChanged
上调用函数。我错过了什么吗?我甚至尝试了故事板实现,但结果仍然不对。我还尝试了UIControlEventTouchUpInside
和其他操作,但都没有调用下面的changePage:
函数。
在 .h 文件中:
@property (nonatomic, retain) UIPageControl *introPageControl;
-(IBAction)changePage:(id)sender;
在.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 :(
}