Reputation:
I have a scroll view which contain a view and view have five images in want a pagecontrol to show the navigation status but the page control hides behind the images. I tried everything searched internet but cant fined anything.
Implementation.h
@interface ScrollSecondViewController : UIViewController
{
IBOutlet UIView *scrContentSizeView;
IBOutlet UIScrollView * scrollView;
}
@property (nonatomic, weak) IBOutlet UIPageControl *pageControl;
@end
Implementation.m
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationItem setTitle:@"Scroll View"];
scrollView.contentSize = CGSizeMake(scrContentSizeView.frame.size.width, scrollView.frame.size.height);
scrollView.clipsToBounds = YES;
[scrollView setContentOffset:CGPointMake(750, 0) animated:YES];
// Do any additional setup after loading the view.
}
- (void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
_pageControl.currentPage = scrollView.contentOffset.x / scrollView.frame.size.width;
}
Upvotes: 1
Views: 387
Reputation: 274
In the viewDidLoad method you should add the following code as the last method you call after adding all subviews.
- (void)viewDidLoad {
[super viewDidLoad];
//do what u want
//this should be last
[self.view bringSubviewToFront:self.pageControl];
}
Upvotes: 2