ios - UIScrollView 和问题设置 UIPageControl 的当前页面

标签 ios ios6 uiscrollview

我正在尝试设置 UIPageControl 并需要设置 currentPage;我有以下内容,但一旦分配了值 self.pageControl.currentPage,它始终等于 0,即使它应该是正确的值。这是我第一次使用 UIPageControl,我认为我错过了一些非常基本的东西;可能总是在某个地方重置为 0。提前谢谢

这是我的代码

- (void)scrollViewDidEndDecelerating:(UIScrollView *)aScrollView
{
    self.pageControl.currentPage = (int) floor((self.scrollView.contentOffset.x + 0.25)/320.0f);
    int this_page=(int)(self.scrollView.contentOffset.x + 0.25)/320.0f;
  self.pageControl.currentPage=this_page;
  NSLog(@"here is property %d", self.pageControl.currentPage);
  NSLog(@"here is this_page %d", this_page);
  self.pageControl.currentPage=4;
  NSLog(@"here is property after manual set %d", self.pageControl.currentPage);

}

和我的 NSLog 输出。

2013-03-03 10:19:14.204 Lt[32045:11303] here is property 0
2013-03-03 10:19:14.206 Lt[32045:11303] here is this_page 1
2013-03-03 10:28:03.993 Lt[32209:11303] here is property after manual set 0
2013-03-03 10:19:15.449 Lt[32045:11303] here is property 0
2013-03-03 10:19:15.449 Lt[32045:11303] here is this_page 2
2013-03-03 10:28:03.993 Lt[32209:11303] here is property after manual set 0

最佳答案

很可能self.pageControl为零,即您从未正确连接 socket 。否则页面控件本身配置不正确,例如您从未设置numberOfPages

顺便说一句,在 iOS 6 中协调页面控件与分页 ScrollView 的最简单方法是使用 UIPageViewController。

关于ios - UIScrollView 和问题设置 UIPageControl 的当前页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15189088/

相关文章:

ios - 设备上的 View 大小与 swift 中的 Storyboard不同

ios - 尝试将 AudioKit 框架上传到 GitHub

uiviewcontroller - iOS6 游戏套件

ios - 如何仅播放YouTube视频的音频?

facebook - iOS 6 facebook 服务器无法完成此访问请求无效应用程序

ios - 启用分页和缩放的 UIScrollView 图像/照片查看器

iphone - Organizer Archive 未验证 Iphone APP

ios - 如何删除 UISlider 控件左侧的蓝色阴影?

ios - UIScrollView 偏移 contentView 中的内容

ios - 使用drawRect延迟加载UIViews : drawing