[英]Bottom UIScrollView Infinite Scrolling ios
我正在嘗試在屏幕底部無限滾動。我要做的是創建了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];
}
一個簡單的解決方案是使用具有n (在您的情況下為8)行的UITableView
,並在顯示第8行時在其中顯示按鈕0等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.