Auto Layout Contraints Differ With Hide Tab In viewDidLoad - view

I built my project as a Tab Bar Application that utilizes the UITabBarController.
I've set all the auto layout constraints for all my subviews and it looks right in the preview. When my application first starts, I hide the tab bar in viewDidLoad. Once a button is clicked, I hide the view and show the tab bar.
My problem is that the constraints adjusted themselves to the hidden tool bar and everything shifts down the length of the height of the tab bar. If I go to the second tab and back to the first, the constraints are back to normal. Is there an easy way to deal with this? I need to find out how to either hide the tab bar in other way that doesn't compromise my constraints, or how to allow the first view to extend down over the tab bar. Please help.
Hiding tab bar liks so.
[self.tabBarController.tabBar setHidden:YES];
Oddly enough. When I go to set the vertical constraint to the bottom of the view, the distance to the bottom of the view is equal to the top of the tab bar even though the height of the tab bar is 50 px.

Related

Hidden window title with accessory view

I want to have a window with a hidden title, as seen in Safari or Xcode, but using a titlebar accessory view instead of a toolbar (I want more control over arrangement and content than a toolbar provides). Is this doable?
I haven't quite been able to make it work. If I set my window's titleVisibility to hidden, and my accessory view's layoutAttribute is bottom, then the title area is empty except for the standard close/minimize/zoom buttons, and my accessory view appears below that.
If I change the layoutAttribute to right, then my accessory view appears to the right of the standard buttons where I want it, but the bottom is cut off because the title bar isn't tall enough, and the view also doesn't resize horizontally with the window.
Is there a way to make this work? Or do I have to use a toolbar?
Update: I used Xcode's visual debugger to examine Xcode's own title bar, and found that it is using a toolbar. The debugger refuses to attach to Safari, so I'm left wondering how it does the new tab button. I imagine that button is a right-pinned accessory view, and the rest is a normal toolbar. Safari's toolbar is still customizable, so that seems most likely.
I decided to go ahead and use a toolbar, and it's working pretty well.
I took my NSTitleBarAccessoryController subclass and made it inherit from NSViewController instead.
I created a non-customizable toolbar for my window, with a single "Image Toolbar Item" in both the allowed and default sets.
The toolbar item has a height of 32 and a max width of 10000 so it can stretch to fill the title bar.
In my toolbar delegate, in toolbarWillAddItem:, I instantiate the view controller from the nib and put its view into the item.
A text label that is effectively the new window title has its value bound to the window's title.
To match the spacing in Xcode's title bar, use a left and right margin of 1 pixel (zero will cut off the edges) and a top margin of 5.
window.titleVisibility = .hidden moves the toolbar into the title area.

embedded views lotus notes horizontal scroll bar

I have an interesting embedded view issue in lotus notes. I have the view embedded into a table cell and have turned off scrolling and extend last column options and the scroll bars don't display, everything looks good.
But as soon as I check the display actions option the horizontal scroll bar scows. I only have one button. Is there anything I can do to hide the scroll bar?
You can show or hide only both the scrollbars at once. Impossible to set a property for only one scrollbar.

UIScrollView not displaying

I have a very simple application.
There is a toolbar on the top, and the bottom.
The bottom toolbar needs to be in a UIScrollView because it's buttons goes off the screen.
But when I test my application on a iPhone 4G, the scrollbar, and it's content, doesn't display.
When I test it on a iPod 5G, everything is where it should be.
I'm not using any coding currently, this is all being done in the storyboard.
Since there is a difference in the screen size of iPhone4G and iPod 5 the UI will resize resulting in the shrinking of all added subviews.
There are two solutions to fix your problem.
1) Add both toolbars. Select the toolbar at the bottom of the screen and in the Editor menu
Editor > Embed In > Scroll View
This will make sure that the UI works out of the box.
2) This is the second way (I am guessing you've created your UI this way)
-> Drag a scroll view
-> Add Tool bar as its sub view.
-> Now we need to set the springs (In our case autolayout attributes.)
The image below will help you understand better
The first constraint "Height Equals" can be added as follows
Editor > Pin > Height
Now Select and edit the leading space to: attribute
and in the drop down menu select "Less than or Equal"
This is similar to setting "UIViewAutoresizingFlexibleTopMargin" as the auto resizing mask.

NSWindow's title as indicator popup button

I'm trying to make my first Cocoa app (previously I was making iOS apps) and what I wish to do for my custom view is make it's title clickable with indicator (accessory) triangle facing down.
Clicking the title would open a popup/menu with my items.
How is that doneable in Cocoa?
Rdelmar's answer is probably the easiest way to go, but may not do exactly what you might want to do (which is replace the actual title with a pop up item, instead of having a popup button under the title in the toolbar area). With respect to functionality your application will probably work just as well using the toolbar.
If, however, you truly want to replace the actual title, the means of going about this would be to set the NSWindow title text to #"" to hide it, and redraw it by sticking in your own view.
[[[theWindow contentView] superview] addSubview:theSubview];
This basically tells the superview of the main content view to add another subview (direct "translation" from the code), and you'll have to tinker with the frame of this new subview to have it be positioned where the title should be positioned (as now it's free to be placed anywhere in the window frame, including on top of the title bar, as opposed to simply inside the content view).
theSubview can be your popup button, or whatever you want, and you'll also probably have to custom draw the popup button to match the original drawing of the window title.
You can do this by adding a toolbar to your window in IB. Once, you add the toolbar, you can double click on it to open the customizer view of it. Drag a popup button into the Allowable Toolbar Items area and after it is inserted there you can drag it into the bottom area which shows the layout of the toolbar -- you can also drag out any of the default items there that you don't want.

How to make a scrolling bar of buttons (buttons bar) with Cocoa?

I would like to have buttons inside a scroll view (or another solution to creating a scrollable button bar).
I have buttons placed side by side in a row along the top of a view. As a user resizes the window to be less wide, fewer buttons can be seen.
When all the buttons cannot be viewed, I would like the user to still be able to access all the buttons by scrolling horizontally through them.
To visualise this, imagine in Safari if you open too many tabs to fit in the window - I would like the user to be able to scroll to the right and reveal the tabs that weren't on the screen.
You need to deselect the springs (for the custom view of the scroller) in the autosizing setter so that the view doesn't shrink along with the scroll view when you resize.

Resources