小编use*_*207的帖子

无法获取UICollectionView当前页面

collection view使用以下代码在水平方向上对其进行了分页.

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.collectionView.pagingEnabled = YES;
    self.collectionView.directionalLockEnabled = YES;
    self.collectionView.bounces = NO;
    self.collectionView.showsHorizontalScrollIndicator = NO;
    self.collectionView.delegate = self;

    [self setup];

    self.pageControl.currentPage = 0;

    self.pageControl.numberOfPages = floor(self.collectionView.contentSize.width /   self.collectionView.frame.size.width) + 1;
}
Run Code Online (Sandbox Code Playgroud)

pageControl用来表示我有多少页面和当前页面.

我使用类似于以下链接的方法来确定当前页面.

iOS6 UICollectionView和UIPageControl - 如何获取可见单元格?

UICollectionView:页面控制的当前索引路径

如下.

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    NSInteger currentPage = self.collectionView.contentOffset.x / self.collectionView.frame.size.width;
    self.pageControl.currentPage = currentPage;
}
Run Code Online (Sandbox Code Playgroud)

但是,它不起作用.当我滑动collection view到下一页时,pageControl静止指向第一页.它不会改变它的价值.

我打印出self.collectionView.contentOffset.x值,它总是在框架内(这是第一页,即使我已经刷到下一页),它永远不会进入下一页.

我做错什么了吗?

ios uicollectionview

5
推荐指数
1
解决办法
3661
查看次数

如何将ipython从0.12升级到0.13?

我在Mac Lion OS上使用最新的免费版Enthought包.ipython附带的包装是0.12.如何将其升级到0.13?

当我按照说明操作并运行以下命令时

sudo easy_install ipython[zmq,qtconsole,notebook,test]
Run Code Online (Sandbox Code Playgroud)

我有以下错误:

Searching for ipython[zmq,qtconsole,notebook,test]
Best match: ipython 0.12.1
Adding ipython 0.12.1 to easy-install.pth file

Using /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages
Processing dependencies for ipython[zmq,qtconsole,notebook,test]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/easy_install", line 10, in 
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1915, in main
    with_ei_usage(lambda:
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1896, in with_ei_usage
    return f()
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1919, in 
    distclass=DistributionWithoutHelpCommands, **kw
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/distutils/dist.py", line 972, in run_command …

ipython

4
推荐指数
2
解决办法
1万
查看次数

标签 统计

ios ×1

ipython ×1

uicollectionview ×1