【发布时间】:2013-12-10 20:36:36
【问题描述】:
我有一个包含 5 张图片的 UIScrollView。我想在滚动视图的底部添加一个 UIPageControl,以便用户可以看到他们所在的页面。
这是我的滚动视图代码:
self.helpScrollView.contentSize = CGSizeMake(320 * 5, 436);
UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(320 * 0, 0, 320, 436)];
image1.image = [UIImage imageNamed:[NSString stringWithFormat:
@"Guide Page One.png"]];
[self.helpScrollView addSubview:image1];
UIImageView *image2 = [[UIImageView alloc] initWithFrame:CGRectMake(320 * 1, 0, 320, 436)];
image2.image = [UIImage imageNamed:[NSString stringWithFormat:
@"Guide Page Two.png"]];
[self.helpScrollView addSubview:image2];
UIImageView *image3 = [[UIImageView alloc] initWithFrame:CGRectMake(320 * 2, 0, 320, 436)];
image3.image = [UIImage imageNamed:[NSString stringWithFormat:
@"Guide Page Three.png"]];
[self.helpScrollView addSubview:image3];
UIImageView *image4 = [[UIImageView alloc] initWithFrame:CGRectMake(320 * 3, 0, 320, 436)];
image4.image = [UIImage imageNamed:[NSString stringWithFormat:
@"Guide Page Four.png"]];
[self.helpScrollView addSubview:image4];
UIImageView *image5 = [[UIImageView alloc] initWithFrame:CGRectMake(320 * 4, 0, 320, 436)];
image5.image = [UIImage imageNamed:[NSString stringWithFormat:
@"Guide Page Five.png"]];
[self.helpScrollView addSubview:image5];
self.helpScrollView.pagingEnabled = true;
self.helpScrollView.showsHorizontalScrollIndicator = NO;
我已将 UIPageControl 拖到我的 xib 文件中的滚动视图上,但我不知道如何链接它们。我该怎么做?
【问题讨论】:
标签: ios objective-c uiscrollview uipagecontrol