iOS   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 带UIPageControl的GMGridView大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述@H_616_4@ 我正在做一个项目,并研究使用这里找到的GMGridView: https://github.com/gmoledina/GMGridView. 有人用它并添加了UIPageControl吗?如果是这样,怎么办呢? 谢谢您的帮助. 您需要进行以下更改: – 1.)In Demo1ViewController.h do @interface Demo1ViewController : UIV
我正在做一个项目,并研究使用这里找到的GMGridView: https://github.com/gmoledina/GMGridView.

有人用它并添加了UIPageControl吗?如果是这样,怎么办呢?

谢谢您的帮助.

解决方法

您需要进行以下更改: –

1.)In Demo1ViewController.h  do
    @interface Demo1ViewController : UIViewController
    {
        UIPageControl *pageCont;
    }
    @end

2.)In Demo1ViewController.m  do

In load view method write:-

      pageCont=[[UIPageControl alloc]init];
        pageCont.numberOfPages=10// set this according to your @R_513_10586@l pages
        pageCont.BACkgroundColor=[UIColor blueColor];
        [pageCont addTarget:self action:@SELEctor(pagechanged:) forControlEvents:UIControlEventValueChanged];
        pageCont.frame=CGRectMake(0,320,30);// set frame as your requirements
        [self.view addSubview:pageCont]; 
        _gmGridView.delegate=self;

    and add these two methods

    -(IBACtion)pagechanged:(id)sender
    {
// add code according  to your requirements if needed

    }

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
        CGFloat pageWidth = _gmGridView.frame.size.width; 
        float fractionalPage = _gmGridView.contentOffset.x / pageWidth;
        NSInteger page = lround(fractionalPagE);
        pageCont.currentPage = page; 
    }

这适用于gmgrid视图的水平布局,如果需要,您可以更改didscroll方法的逻辑以进行垂直滚动.它可能会帮助你.快乐的编码!

大佬总结

以上是大佬教程为你收集整理的iphone – 带UIPageControl的GMGridView全部内容,希望文章能够帮你解决iphone – 带UIPageControl的GMGridView所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。