Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIScrollView和问题设置UIPageControl';s当前页面_Ios_Ios6_Uiscrollview - Fatal编程技术网

Ios UIScrollView和问题设置UIPageControl';s当前页面

Ios UIScrollView和问题设置UIPageControl';s当前页面,ios,ios6,uiscrollview,Ios,Ios6,Uiscrollview,我正在尝试设置UIPageControl,需要设置currentPage;我有以下内容,但一旦将该值分配给self.pageControl.currentPage,它始终等于0,即使它应该是正确的值。这是我第一次使用UIPageControl,我想我缺少了一些真正基本的东西;可能总是在某个地方重置为0。提前thx 这是我的密码 - (void)scrollViewDidEndDecelerating:(UIScrollView *)aScrollView { self.pageContr

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

这是我的密码

- (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
为零,即您从未正确连接插座。或者页面控件本身配置不正确,例如,您从未设置
numberOfPages


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

是的,我想你是对的。手动设置不会更新pageControl值