我有一个滚动视图,其中包含一个视图和视图,其中有五个图像需要一个页面控件来显示导航状态,但页面控件隐藏在图像后面。我尝试了一切搜索互联网,但没有罚款。
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;
}
答案 0 :(得分:2)
在viewDidLoad方法中,您应该添加以下代码作为添加所有子视图后调用的最后一个方法。
- (void)viewDidLoad {
[super viewDidLoad];
//do what u want
//this should be last
[self.view bringSubviewToFront:self.pageControl];
}