【发布时间】:2013-10-16 14:25:33
【问题描述】:
我想这样滚动 1 2 3 1 2 3
我有一些按钮,假设是 10,我想在无限滚动中显示。
numbercolors=[[NSMutableArray alloc] init];
//total count of array is 49
numbercolors = [NSMutableArray arrayWithObjects:@"25",@"26",@"27",@"28",@"29",@"31",@"32",@"33",@"34",@"35", @"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35", @"0",@"1",@"2",@"3",nil];
int x=2500;
for (NSInteger index = 0; index < [numbercolors count]; index++)
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(x ,0,29.0,77.0);
button.tag = index;
[button setTitle:[numbercolors objectAtIndex:index] forState:UIControlStateNormal];
[button addTarget:self action:@selector(didTapButton:)
forControlEvents:UIControlEventTouchUpInside];
[coloringScroll addSubview:button];
x=x+70+29;
}
[coloringScroll setContentSize:CGSizeMake(5000+ (29+70)*[numbercolors count], 1)];
[coloringScroll setContentOffset:CGPointMake(2500+(29+70)*11, 0)];
这是我在滚动视图上制作按钮的代码。
如何在 - (void)scrollViewDidEndDecelerating:(UIScrollView *)sender 这个方法中设置无限滚动。
【问题讨论】:
-
如果您希望它真正“无限”,那么您可能想要“平铺”您的显示器,这样“平铺”在一端创建并在另一端移除。有点像 UITableView 是如何完成的。
标签: iphone objective-c ipad uiscrollview ios7