1. ScrollDemoViewController.h
#import <UIKit/UIKit.h>
@interface ScrollDemoViewController : UIViewController<UIScrollViewDelegate> {
IBOutlet UIPageControl *pageControl;
IBOutlet UIScrollView *ScrollView;
IBOutlet UIView *view1;
IBOutlet UIView *view2;
IBOutlet UIView *view3;
}
@property(nonatomic,retain)UIView *view1;
@property(nonatomic,retain)UIView *view2;
@property(nonatomic,retain)UIView *view3;
@property(nonatomic,retain)UIPageControl *pageControl;
@property(nonatomic,retain)UIScrollView *scrollView;
-(IBAction)pageClick:(id)send;
@end
2. ScrollDemoViewController.m文件中添加如下代码:
- (void)viewDidLoad {
[super viewDidLoad];
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width*3, scrollView.frame.size.height);
}
-(void)pageClick:(id)send{
CGRect rect = CGRectMake([pageControl currentPage] * scrollView.frame.size.width, 0,
scrollView.frame.size.width, scrollView.frame.size.height);
[scrollView scrollRectToVisible:rect animated:YES];
[view1 setHidden:YES ];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView1
{
CGPoint offsetofScrollView = scrollView1.contentOffset;
[pageControl setCurrentPage:offsetofScrollView.x / scrollView.frame.size.width];
}
- (void)dealloc {
[pageControl release];
[scrollView release];
[view1 release];
[view2 release];
[view3 release];
[super dealloc];
}
3. ScrollDemoViewController.xib文件如下添加控件:
设置scroll view 的paging Enabled 为选中状态即可
- 大小: 46.6 KB
- 大小: 39.4 KB
分享到:
相关推荐
UIPageControl继承了UIControl基类,默认属于活动控件,它可以与用户进行交互...使用UIPageControl显示当前的UIScrollView正在显示第几页。 当用户点击UIPageControl控件时程序控制UIScrollView自动滚动到相应的页面。
上次上传的资源,现在才发现漏了说一点,要保证首尾两张的图片是同一张。。。。
UIScrollView与UIPageControl的简单应用以及一些非常基本的使用方法
用UIScrollView 创建的轮播图,包含UIPageControl UIScrollView NSTimer
这是iPhone开发之UIPageControl示例程序,具体参考: http://blog.csdn.net/htttw/article/details/7888322
UIScrollView UIPageControl联合使用的demo,非常简单
iOS UIScrollView and UIPageControl 导航控制器 demo
UIPageControl UIScrollView 构成 第一次启动时的软件说明!
主要为大家详细介绍了iOS基于UIScrollView实现滑动引导页的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
IPhone UIPageControl实例
基于UIScrollVIew 和UIPageControl的相册,相片可以放大缩小,当活动到其他页面,在返回时候放大或者缩小的相片恢复到原来的大小.
1.自动滑动图片,UIPageControl会随着图片滑动而改变; 2.用户可以手动切换图片,左右切换均可,当用户手动滑动图片时,图片停止自动切换; 3.实现了图片的循环播放; 4.UIPageControl可点击从而实现向左或右滑动,...
UIPageControl,我叫它分页点,可以用点控制scrollview的翻页,或者翻页的时候点的指示变换。
iOS基础——通过案例学知识之LaunchScreen、APPIcon、StatusBar、UIScrollView、UIPageControl
UIPageControl分页控件的例子简单来说即是我们平时翻动多个桌面页时及底部带有的圆点页码标注,这里我们来看一下iOS App开发中的UIPageControl分页控件使用小结,需要的朋友可以参考下
iphone中的基础控件UIPageControl,适合初学者,主要学习UIPageControl的常用属性设置、点击事件、以及和scrollView结合可以实现应用首次使用时图片帮助效果等
见标题,没有用到xib,开发环境是ios7
UIScrollView 无限自动循环 类似商品推荐产品图无限循环,配合UIPageControl使用
ios代码,可以根据博客来详细了解http://blog.csdn.net/u010335966/article/details/8832940