Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

A layout control for iOS? #47

Closed
mamcx opened this issue Aug 24, 2011 · 10 comments
Closed

A layout control for iOS? #47

mamcx opened this issue Aug 24, 2011 · 10 comments

Comments

@mamcx
Copy link

mamcx commented Aug 24, 2011

I want a better way to build views by code. Now is necessary do math for the subViews, and I hate more recalculate it for the orientation changes. Using IB is not enough, still work bad in orientation changes for something barely complex.

A Layout control will help a lot in build dynamic views, and abstract the differences between iPad/iPhone.

Something like:

- (void)loadView
{
    UIView *section = [self.view addSection:RESIZE_ALL columns:2];

    [section addTopLeft:subView1 inColumn:1];
    [section addTopRigth:subView2 inColumn:2];
}

Or something better.

@jverkoey
Copy link
Owner

I have wanted something similar recently, but I think Apple is making some good headway with their new autolayout tech.

http://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/AutolayoutPG/AutolayoutPG.pdf

@jverkoey
Copy link
Owner

Anything we build would either have to complement autolayout or be something completely different.

@mamcx
Copy link
Author

mamcx commented Aug 26, 2011

Is my understanding that is only for OSX apps..

@jverkoey
Copy link
Owner

I think it will be making its way to iOS soon, likely in iOS 5 or beyond.

That being said, you do raise a good point that the absence of such a framework in current distributions of iOS is really crappy. Would you be interested in tackling a feature like this?

@jverkoey
Copy link
Owner

Ah, you're absolutely right that it's not even going to be in iOS 5. Ah well, that lends a pretty strong incentive to build this out for iOS then :)

If this feature is pursued, we should aim to try to provide feature parity with autolayout on iOS, under the assumption that it will likely be deprecated someday by Apple.

@grgcombs
Copy link

grgcombs commented Sep 2, 2011

Have either of you looked at @nextmunich's NMView and NMViewController? They've got some great stuff to deal with complex view layouts, and automatically handle rearranging upon orientation changes, etc.

@jverkoey
Copy link
Owner

jverkoey commented Sep 3, 2011

Sweet, our work looks done here :)

@jverkoey jverkoey closed this as completed Sep 3, 2011
@jverkoey
Copy link
Owner

jverkoey commented Sep 3, 2011

Just to be fair as a follow-up here, it appears that NMView still depends on IB. Perhaps there may still be room to create a non-IB solution. Closing this issue for now until someone proves they want this bad enough and writes a design doc for the feature.

@grgcombs
Copy link

grgcombs commented Sep 3, 2011

Hrm... At one time I thought they had some examples that showed it with and without NIBs, but I haven't looked at it in a little while. In any event, it's neat stuff. There's always the possibility of exporting an NMView NIB to objective-c source using nib2objc, but that's probably not at all what anyone is after ;-)

@nextmunich
Copy link

@grgcombs, thanks for suggesting NMView ;-)

@jverkoey, we've initially created NMView as a means for building complex view components in iOS via IB that can be re-used across controllers. This was, in principle, possible by creating UIViewController subclasses but properly forwarding lifecycle events (rotation, view visibility) is a complex topic and not so easy to get right. So that's NMView's main purpose: create a re-usable view component which can be layouted using IB.

Based on this premise, we've also added the ability to define multiple different layouts of the same view for different aspect ratios (ie. for different layouts in landscape / portrait modes) via IB which are automatically appliead on frame / bounds changes. Eventually this has been refactored to work on the basis of a layout manager which is responsible for automatically layouting a UIView's subviews. As an example, the aspect-ratio code is a layout manager along with a layout manager that automatically lays out subviews in a grid.

The project contains NMView as a library and several targets showcasing NMView's features. Hope this clarification helps!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants