初识UIPageView

老师布置的作业:实现和ScrollView一起运用啊,选中Scroll中的元件,在UIPageControl的小点点随之变化(说到小点点,我们楼下的全家超市买满12元就可以集一个小点点,16个小点点可以兑换1个机器猫-小叮当啊)算了,还是看UIPageControl吧,在这之前是一点点都不知道的,就看着帮助文档看一下它的成员和方法吧。

Overview

 you see the UIPageControl class to create and manage page controls,A page control is a succession of dots centered in the control. 

succession :连续的,连续不断的人,继承

successor:继承人,那时还做考研的阅读理解,说到starbucks 的successor 无所作为神马的

dot s果真不认识这个单词,dot 是小圆点 dots 人家是复数好不好,连续的小圆点

dot matrix 点阵 matrix  矩阵的意思 dota (defence of the ancientdots

specify 

Task

currentPage      

The current page, shown by the receiver as a white dot.

@property(nonatomic) NSInteger currentPage

numberOfPages

The number of pages the receiver shows (as dots).

@property(nonatomic) NSInteger numberOfPages

Discussion

The value of the property is the number of pages for the page control to show as dots. The default value is 0.


还有一些方法

  •   hidesForSinglePage  property

Updating the Page Display

  •   pageIndicatorTintColor  property
  •   currentPageIndicatorTintColor  property
  •   defersCurrentPageDisplay  property
  • – updateCurrentPageDisplay

Resizing the Control

  • – sizeForNumberOfPages:
以后再看吧,今天要去完成我的小作业~~~~~~~

@synthesize myScrollView,myPageControl;


- (void)viewDidLoad

{

    [super viewDidLoad];

    [myScrollView setContentSize:CGSizeMake(320*6+10*6, 460)]; //setContentSize:

    //myScrollView.delegate = self;    //也可以在XIb中拖拽实现协议,记得协议啊

    for (int i = 0; i<7; i++) //用循环的方法构造我的scroll视图

    {

        UIImageView *pic = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"scroll%d",i]]];

        //UIButton *btn =[[UIButton alloc]initWithFrame:CGRectMake(320*i, 10, 320, 460)];

        //[myBtn addObject:btn];

        [pic setFrame:CGRectMake(320*i+10*i, 0, 320, 460)];

        [myScrollView addSubview:pic];

    }

    

    [myPageControl addTarget:self action:@selector(selectorPage) forControlEvents:UIControlEventValueChanged];//pageControl的选择器方法

// Do any additional setup after loading the view, typically from a nib.

}


- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

//协议

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{

    int index = myScrollView.contentOffset.x/320;

    myPageControl.currentPage = index; 

    

}

//自定义的选择器方法实现点击小点点控制视图的滚动

- (void)selectorPage

{

    int page = myPageControl.currentPage;

    [myScrollView setContentOffset:CGPointMake(320*page, 0)]; // 注意坐标原点啊~~~

}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值