I have rows of subviews within a UIScrollView that I want to rearrange after rotating to landscape mode. Ideally, I want to have 5 buttons per row with the total number of rows determined by the button height and how many buttons there are total (plus some padding).
The problem I am having is how to iterate through subviews while also iterating through x-position for 5 buttons on the row and then changing y-position after I hit the 5 button limit to start a new row.
Right now I can iterate through subviews, but I'm not sure how to automate setting the frame for 5 per row and then changing the y-position to start a new row. Any suggestions are greatly appreciated!
for (UIView *subview in someScrollView.subviews)
{
if (subview.tag >= 100) {
[subview setFrame: CGRectMake(x, y, buttonWidth, buttonHeight)];
NSLog(@"%.1f %.1f %d %d on subview %d", x, y, buttonWidth, buttonHeight, subview.tag);
}
}