I’m trying to create a “GridView” style table within a UIScrollview which itself is within a restricted space. I put it within a Scrollview so that the user would be able to scroll down if there are more rows than can be displayed.
My storyboard for the relevant section looks like this:

To test it I tried filling it with UILabels, with this code:
for (int i = 0; i < 15; i++)
{
UILabel *cliLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, (60+(i*30)), 80, 40)];
UILabel *cliColum2Label = [[UILabel alloc] initWithFrame:CGRectMake(110, (60+(i*30)), 150, 40)];
UILabel *cliColum3Label = [[UILabel alloc] initWithFrame:CGRectMake(270, (60+(i*30)), 80, 40)];
UILabel *cliColum4Label = [[UILabel alloc] initWithFrame:CGRectMake(360, (60+(i*30)), 80, 40)];
[cliLabel setText:@"Column 1"];
[cliColum2Label setText:[NSString stringWithFormat:@"Column 2, row %d", i]];
[cliColum3Label setText:@"Column 3"];
[cliColum4Label setText:@"Column 4"];
[self.cliTableScrollView addSubview:cliLabel];
[self.cliTableScrollView addSubview:cliColum2Label];
[self.cliTableScrollView addSubview:cliColum3Label];
[self.cliTableScrollView addSubview:cliColum4Label];
}
This results in the following:

As you can see, there are more rows than can be displayed within the scroll view.
What I’d like to know is how to modify the above so that a scroll-bar appears, giving access to the out-of-bounds rows.
UIScrollViewdoesn’t know how much it has to scroll, you need to tell it by providingcontentSize. For example, at the end of your loop: