-(void)viewDidLoad{
[super viewDidLoad];
UIPageControl* pc = [[[UIPageControl alloc] initWithFrame:CGRectMake(100, 400, 120, 27)] autorelease];
pc.numberOfPages = 3;
pc.currentPage = 0;
[pc addTarget:self action:@selector(pageChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:pc];
[self pageChanged:pc];
}
-(void)pageChanged:(UIPageControl*)pc{
NSArray *subViews = pc.subviews;
for (int i = 0; i < [subViews count]; i++) {
UIView* subView = [subViews objectAtIndex:i];
if ([NSStringFromClass([subView class]) isEqualToString:NSStringFromClass([UIImageView class])]) {
((UIImageView*)subView).image = (pc.currentPage == i ? [UIImage imageNamed:@"RedPoint.png"] : [UIImage imageNamed:@"BluePoint.png"]);
}
}
}