-
Notifications
You must be signed in to change notification settings - Fork 1
How to use with UIScrollView? #18
Comments
So if I got the problem correctly, you'd like to layout items with a linear layout vertically for example and then figure out what the height would be for example for 10 items of a height of 20px? Honestly I agree its a bit tricky and not obvious how to achieve this atm. I will improve that in the future. In the meantime the following might help: Actually after calling layout all your childs will be placed accordingly the layout settings that you've provided. Note that you can call layout at any time. Just do it right after you specified all your layout details. |
A small example: - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIScrollView *childView = [[UIScrollView alloc] init];
childView.backgroundColor = [UIColor greenColor];
[self.view addSubview:childView];
self.childView = childView;
self.childView.frame = self.view.bounds;
self.rootLayout = [[MKLinearLayout alloc] initWithView:self.childView];
self.rootLayout.orientation = MKLayoutOrientationVertical;
// Construct your layout
for (int i = 0; i < 100; i++) {
UIView *greyView = [[UIView alloc] init];
greyView.backgroundColor = [UIColor grayColor];
MKLayoutItem *item = [self.rootLayout addSubview:greyView];
item.size = CGSizeMake(100.0f, 100.0f);
}
// Manually let the layout calculate its childs sizes
[self.rootLayout layout];
MKLayoutItem *item = self.rootLayout.items.lastObject;
self.childView.contentSize = CGSizeMake(item.subview.frame.origin.x + item.subview.frame.size.width,
item.subview.frame.origin.y + item.subview.frame.size.height);
} |
Hello
I'm using this lib to layout all my views. But this library doesn't set measured height and other things. How to use this lib with UIScrollView because there we must set contentSize property :(
The text was updated successfully, but these errors were encountered: