0

I am trying to make infinite scroll at bottom of screen.What i have done is I have created 8 buttons and have to make it scroll infinite(after Button7-->Button0-->Button1...). I am not getting what to do next. Here is the code what i have done.

- (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];

}
Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
Saheb Singh
  • 555
  • 4
  • 18
  • 3
    https://developer.apple.com/library/ios/samplecode/StreetScroller/Introduction/Intro.html and http://stackoverflow.com/questions/19268456/how-can-i-make-uiscrollview-infinite-in-ios – iPatel Feb 21 '14 at 12:53
  • https://github.com/canopas/MarqueeScroll – SPatel Jan 19 '21 at 04:42

1 Answers1

0

An easy solution would be to use an UITableView with n (in your case 8) rows, and when row number 8 is displayed show button 0 in it etc.

TheEye
  • 9,280
  • 2
  • 42
  • 58