我已经看到很多消息来源说可以在 UITableViewCell 中包含一个带有 UIPageControl 的 UIScrollView以便能够水平滚动(通过可选图像列表),但是找不到任何我想要的原始示例。我已经让我的滚动视图“工作”了,但我不确定如何前进 - 希望有人可以给我一些指导。
在我的 cellForRowAtIndexPath 中,我创建了一个单元格,并将 scrollView 和 pageControl 添加为子视图。
UITableViewCell *cell = [self.challengeListView dequeueReusableCellWithIdentifier:SubmitChallengeCellIdentifier];
if(cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SubmitChallengeCellIdentifier] autorelease];
cell.frame = CGRectMake(0, 0, 1000, 50);
}
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, tv.frame.size.width, 50)];
[scrollView setContentSize:CGSizeMake(1000, 50)];
[[cell contentView] addSubview:scrollView];
pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 50, tv.frame.size.width, 50)];
[pageControl setNumberOfPages:4];
[[cell contentView] addSubview:pageControl];
我附上了正在显示的屏幕截图
主视图的底部是我的 UITableView,其中包含 scrollView/pageControl(它会水平滚动,因为我可以看到 scrollerIndicator 显示了这一点),并且我将其方法设置为以下内容:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
我的 Scroll 视图将显示一个“ horizontalScroller ”,我可以来回滚动,但显然那里没有内容。 如何使用“可点击”图像列表填充 tableView/scrollView?任何方向都将不胜感激- 最好不是“嘿,这家伙做的有点相似,看看这个链接”,但也许更多的是解释如何正确实现这个功能(特别是关于 iOS 3.0+ - 这是我的了解 Apple 让我们的生活更轻松地实现了这一点)