【发布时间】:2014-02-21 12:45:23
【问题描述】:
我正在尝试在屏幕底部进行无限滚动。我所做的是 我已经创建了 8 个按钮并且必须让它无限滚动(在 Button7-->Button0-->Button1...之后)。我不知道下一步该做什么。 这是我所做的代码。
- (void)viewDidLoad
{
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 450, self.view.frame.size.width, 35)];
int x = 0;
for (int i = 0; i < 8; i++) {
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x, 0, 100, 20)];
[button setTitle:[NSString stringWithFormat:@"Button %d", i] forState:UIControlStateNormal];
button.backgroundColor=[UIColor blackColor];
[scrollView addSubview:button];
x += button.frame.size.width;
}
scrollView.contentSize = CGSizeMake(x, scrollView.frame.size.height);
scrollView.backgroundColor = [UIColor redColor];
[self.view addSubview:scrollView];
}
【问题讨论】:
标签: ios uiscrollview