我一直在这个工作了很长一段时间,我只是无法弄清楚。UIPageControl消失
我的页面控件不断消失。
我最初有我的代码,所以它的工作,但它显示pagecontrol之间滚动通过视图。
我怎么现在已经改变了它,当它向前滚动两个视图时显示,而其他视图不能用于页面控制时,它甚至不显示。当您向后滚动到第一个视图时,页面控件也会消失(包括它在运行我的代码开始时正在运行的两个)。
我所有的视图都具有相同的设置,所以我不确定为什么这样保持。发生
下面是代码的标题,我使用:
- (void)scrollViewDidScroll:(UIScrollView *)sender {
if (_pageControlUsed || _rotating) {
// do nothing - the scroll was initiated from the page control, not the user dragging
return;
}
// Switch the indicator when more than 50% of the previous/next page is visible
CGFloat pageWidth = self.scrollView.frame.size.width;
int page = floor((self.scrollView.contentOffset.x - pageWidth/2)/pageWidth) + 1;
if (self.pageControl.currentPage != page && page>=0 && page<self.childViewControllers.count) {
UIViewController *oldViewController = [self.childViewControllers objectAtIndex:self.pageControl.currentPage];
UIViewController *newViewController = [self.childViewControllers objectAtIndex:page];
[oldViewController viewWillDisappear:YES];
[newViewController viewWillAppear:YES];
self.pageControl.currentPage = page;
[oldViewController viewDidDisappear:YES];
[newViewController viewDidAppear:YES];
_page = page;
CGRect frame = pageControl.frame;
frame.origin.x = pageWidth;
pageControl.frame = frame;
}
}
如果有任何人知道我去错了,可以帮助我,这将是辉煌
请。意识到我还是相当新的编程和Xcode中。
请检查链接全教程的简单且有效的方法来使用页面控制研究不计页面滚动元素 – iphonemaclover