Do we need autolayout and constraints for an OSX app that has a fixed interface size? - macos

Think before you answer because this question may be deeper than it appears.
Do we really need autolayout and constraints for an OSX app that has a fixed interface size?
The only reason for constraints and autolayout on iOS is the different sizes when you rotate the application or between devices but on OSX the reason may be scaling the interface, because there is no rotation. In this specific case the interface has a fixed size.

You interface is really fixed? No resizable windows or anything? If so, nope, you totally don't need autolayout. Just disable the "Use Auto Layout" checkbox in the File Inspector for your xib. That will allow you to use the old-fashioned Autoresizing masks, which, if your app truly has a fixed interface size, you don't even need that.
Layout your interface in IB however you like, and you're done.

I'm not sure if I thought deep enough or onderstand the interface builder enough, but I found out that the buttons keep the size I want them to if I use the constraints. Without constraints and word wrap on, your (my) buttons resize to fit around the text.
Also when you need to resize subviews to fit the content they're showing and you don't have constraints set, you tend to get a messy interface inside your window. My experience is that constraints not only help you when your window resizes. It keeps your interface objects placed correctly in position of one another and with the right size even when content in the different view objects change.

Related

Auto Resizing in Xcode 8

As I know, before XCode 7 appear, we have Auto Resizing go with Auto Layout (appear in XCode 5), but when XCode 7 appear, Auto Resizing be removed and this appeared again in XCode 8. My question are:
Why Apple put back this feature in XCode 8? Do this feature have
some new functions than previous?
We can use Auto Resizing with Auto Layout in the same page. What are
the benefits of using parallelism like that?
I searched in Apple document but not find info about Auto Resizing
Supply any document link or keyword will be appreciated. Thanks
Autoresizing wasn't removed previously, when autolayout was introduced. But in Interface Builder it was available only at the level of the individual xib or storyboard file: such a file either used exclusively autoresizing or exclusively autolayout. Your views configured in code could use either, but you couldn't mix and match with Interface Builder. The change in Xcode 8 is that now you can: one and the same xib or storyboard file can contain views some of which use autoresizing and some of which use autolayout (as you rightly say in your point 2).
The advantage is just what you think it is: freedom of choice, plus easy of use: sometimes autoresizing is all you need, and it can be much faster and simpler to configure. For example, if you want a button to be in the top left corner and stay in the top left corner, you just drag a button from the Library into the top left corner and leave it there; the button's autoresizing configuration is top-left by default, and this configuration won't be turned into autolayout constraints, but will simply be left as is.
However, if you then make a constraint to that button, you have involved it in autolayout, it will now use autolayout, and you will have to add proper constraints for it. In the past, an autoresizing view was "translated" automatically by Interface Builder into an autolayout view if it became involved in autolayout, with automatically generated "autoresizing constraints", but that no longer happens — and this too is a good thing, as it makes it less likely that you'll end up with an accidental conflict between manual constraints and autoresizing constraints.

How to perfectly mimic toolbar buttons as in Finder, Safari, or other default apps?

I'm trying to create an application that would be as standard as possible in terms of style.
An image is worth a thousand words: I can't figure out how to make my buttons the same size as in Apple's programs such as Safari or Finder.
As you can see, the sizing I've set in interface builder don't seem to match the size the buttons get when I run the app, but maybe that part doesn't speak in pixels but in points or something? Also, textured rounded button has only width editable, but not height.
In this case, these are NSButtons, but I guess I'll have a similar problem with other control types...
I found it out! The problem was with neither of these two parts outlined in the screenshot, but in the "Toolbar" item, higher in the hierarchy.
There is a Size attribute in the Attributes inspector which defaults to Small, but you can set it to Regular instead, and then the buttons get the same sizing as in Finder and all.

Scrollable large NSDocument on Macbook Pro 13" XGA display

I'm having all kinds of trouble understanding how NSWindows can have larger documents than the window bounds in them.
Unfortunately, layout and contents prevents me from simply shrinking the document (and I wouldn't want to make the layout cramped for those with larger screens).
A school needs to run this app on their new 13", non-retina MacBook Pros. Scrolling is acceptable to them, but I'm unsure as to the approach, and I'd like your advice on the best way to handle this to avoid forced scrolling on larger screens.
I've tried setting the NSWindow min and max size and embedding the document in a Scroll View. But even though you can see part of the document view sticking out, no scroll bars appear (I have set them to Always in sys prefs).
If this is the way to go I would appreciate a link to a tutorial on this exact subject, because I'm a bit lost with all the measurements and options.
If not I'd like a pointer where to start and what to read. I'm experienced with Cocoa Touch but a relative newcomer to Mac development.
Without more information it sounds like you have embedded a NSScrollView but didn't set up the springs and struts properly to allow the scroll view to resize when its parent view (assuming it's the window) resizes.
You might want to check out Specifying a View’s Behavior as Its Container Resizes in the Interface Builder Help documentation.

iPhone 4/iPhone 5 User Interface compatibility in MonoTouch

I am hoping someone can help me out with this one. I have an app that I am trying to update to get rid of the letterbox look when running on iPhone 5. I have added a Default-568h#2x.png to the project and the application seems to scale correctly. The splash screen on either device looks correct, however I have a toolbar on my "Home" screen that I can't seem to get in the right place. If I get it right for 5, I can't see it on 4s, and if I get it right for 4s, it is very low on 5.
Am I missing something? Do I need to manually move the toolbar that is at the top? And will I need to move all the controls around on all of the screens in the app?
Any advice is appreciated!
Thanks
Here are some tips on using Interface Builder to handle resizing.
Take advantage of the Simulated Metrics in Interface Builder, as shown here:
To do so, select your top-level View, and open the Attribute Inspector. Then, you can select different sizes and orientations to see how your view responds.
Select the Autosizing options as shown here:
In your case, you want a fixed margin above, but a flexible margin below. Note that this is the opposite of the default for a toolbar because the iOS convention is for toolbars to be at the bottom of the view.
Realize that resizing due to rotation and different screen sizes can often be handled the same way. (Thus, if you handle portrait and landscape orientations using Autosizing, iPhone5 layout usually takes care of itself.)

Resizing windows without constraints in IB Xcode 4.4

When laying out an NSPanel in IB I usually open a big window space, add and lay out the content elements, then resize the window to fit.
In Xcode 4.4 the items I add always seem to have space constraints associated with them and resize as I resize the enclosing elements and I can't seem to be able to turn this behaviour off.
I've tried setting the constraints to 'less than or equal', but it has no effect. This is insanely irritating, it's as if I need to build my UI from the outside inward, which is crazy.
Any suggestions?
You need to disable the auto layout check-box in attributes for the xib...
I had the same problem but found this on google: http://gentlebytes.com/2011/09/auto-layout-in-lion/

Resources