UIPageControl + UIScrollView 创建一个页面指示器控件
来源:互联网 发布:元数据和数据的区别 编辑:程序博客网 时间:2024/06/05 16:20
UIPageControl 类提供了一行点来指示当前显示的是多页面视图的哪一页。点击当前颜色鲜艳的页面指示器的左边或右边,会触发 UIControlEventValueChanged 事件,
并启动设置为控件动作的任何方法。你可以通过调用currentPage 查询控件的新值,并通过调整 numberOfPage 属性设置可用的页面数。
代码 :使用UIPageControl 指示器
#define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR] autorelease]
#define RSTRING(X) NSStringFromCGRect(X)
#define BASEHEIGHT 284.0f
#define NPAGES 3
- (void) pageTurn: (UIPageControl *) aPageControl
{
int whichPage = aPageControl.currentPage;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
sv.contentOffset = CGPointMake(320.0f * whichPage, 0.0f);
[UIView commitAnimations];
}
- (void) scrollViewDidScroll: (UIScrollView *) aScrollView
{
CGPoint offset = aScrollView.contentOffset;
pageControl.currentPage = offset.x / 320.0f;
}
- (void) viewDidLoad
{
self.navigationController.navigationBar.tintColor = COOKBOOK_PURPLE_COLOR;
self.title = @"Image Scroller";
// Create the scroll view and set its content size and delegate
sv = [[[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, BASEHEIGHT)] autorelease];
sv.contentSize = CGSizeMake(NPAGES * 320.0f, sv.frame.size.height);
sv.pagingEnabled = YES;
sv.delegate = self;
int i = 0;
// Load in all the pages
for ( i;i < NPAGES; i++)
{
NSString *filename = [NSString stringWithFormat:@"image%d.png", i+1];
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:filename]];
iv.frame = CGRectMake(i * 320.0f, 0.0f, 320.0f, BASEHEIGHT);
[sv addSubview:iv];
[iv release];
}
[self.view addSubview:sv];
pageControl.numberOfPages = 3;
pageControl.currentPage = 0;
[pageControl addTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventValueChanged];
}
- UIPageControl + UIScrollView 创建一个页面指示器控件
- UIPageControl + UIScrollView 创建一个首尾相连页面指示器控件
- UIScrollView & UIPageControl 的创建
- iOS开发之 滚动视图 + 页面控件(UIScrollView + UIPageControl)
- UIPageControl-页面控件
- 【IOS-DEMO】UIScrollView+UIPageControl 实现欢迎页面
- UIScrollView 和 UIPageControl实现页面循环播放
- UIScrollView 按页面滚动视图 UIPageControl
- UIScrollView(滚动视图)/UIPageControl(分页控件)
- UIScrollView、UIPageControl
- UIScrollView--UIPageControl
- UIScrollView、UIPageControl
- UIPageControl+UIScrollView
- UIScrollView,UIPageControl
- UIScrollView+UIPageControl
- UIScrollView、UIPageControl
- UIScrollView&UIPageControl
- UIScrollView/UIPageControl/
- hdu2544最短路
- silverlight 中绘制扇形(前台+后台)
- 初学Java JNI(javac , javah)
- RS-232
- 【转载】Table锁定行列
- UIPageControl + UIScrollView 创建一个页面指示器控件
- Android系统build/core下.mk文件分析
- Exercises 4-14
- iis7.5+win2008 出现 HTTP Error 503. The service is unavailable.
- Oracle中recyclebin的保留策略
- 博客搬家
- Android 常用代码工具
- 微软数据库提供程序类
- Android 根文件系统启动分析