【问题标题】:Bottom UIScrollView Infinite Scrolling ios底部 UIScrollView 无限滚动 ios
【发布时间】: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


【解决方案1】:

一个简单的解决方案是使用带有 n(在您的情况下为 8)行的 UITableView,当显示第 8 行时,在其中显示按钮 0 等。

【讨论】:

  • 其实我是水平滚动的。
  • 然后将tableview旋转90度
  • 你也可以添加水平表格。
猜你喜欢
  • 1970-01-01
  • 2011-03-26
  • 2014-09-23
  • 2012-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-15
相关资源
最近更新 更多