Status bar overlaps toolbar - xcode

I have an app that is largely finished. It uses a toolBar on the top of the view with a few buttons. Under this is a WebView, which only opens one URL and there is no way to get away from this site (that is the point of it).
However, the status bar overlaps the toolbar. My initial temporary solution is to hide the status bar, but I really need it to be there in this app. How can I stop this overlap from happening

Try to put the toolbar's origin as (0, 20) instead of (0, 0).

Related

A control in NSTableCellView is being moved to right automatically after resizing or scrolling

I'm trying to implement a counter view that shows items count in NSTableCellView.
The weird thing is it gets moved to right automatically after resizing window or scrolling the NSOutlineView which has the NSTableCellView.
Here is some screenshots of it. You will be able to see the counter view which shows "42" being moved to right after resize the window.
Following is the init state of the counter view.
Following is the state after resize window.
Following is difference between init position and the position after resize window.
Cell Autoresize Property
Count Button Autoresize Property
I'm guessing this is related to scrollview but I was not able to find more clues about this issue. BTW, official Mail App on Mac works as same with this but the difference is the counter of the Mail app is being changed right after launch so it does not being moved after resize window.
Anybody knows about this? Any thoughts would be appreciated.
Here is a link that allows you to download the sample project that apple provides and you can reproduce what I'm facing.
Sidebar Demo App that providing by Apple.
You just need to change Deployment target before you run it from Project -> Targets -> Deployment Info section.
If I interpret the autoresizing screenshots correctly, the '42' control is behaving as specified. You've pinned the right side of the '42' counter to right side of the cell. And that is where it stays, glued to the right side of the cell.
The cell is pinned to the left side of the tableview and that is where it stays, glued to the left side of the tableview. You have not pinned the right side of the cell to anything and so when you resize, the right side goes where it pleases, only maintaining the specified width of the cell. If you want to glue the right side of the cell to the width of the tableView or column (not sure which it is), pin it. Do specify a minimum width for the cell. If you don't specify a maximum width, or fixed width, the cell will stretch and shrink with resizing. If you fix the width, only the right view or column will stretch.

Button not showing in .nib file

So I downloaded CircleView and tried to change the code. The program came with a button, color wheel, 2 sliders, and a view. When ever I add anything (Slider, button, textfield), on run time the things I added wouldn't show up. What am I not doing?
It's a .nib file.
This is the edit page.
This is what I see when running the program.
As you can see, the button and textfield doesn't appear during run time.
By default, when you add a button, the autoresizing mask (aka "springs and struts") are set to the following:
That means that when you resize the window, the button you added will stay in the same spot it originally was, instead of being "pulled" down with the edge of the window. This could potentially cause the buttons or textfields you added to be hidden behind the circle view once you resize the window large enough.
To prevent that from happening you'll want to change the autoresizing mask of the items to be "pinned" to the bottom edge of the window, so that they look like in the following image:
To do that, click on the red I bar at the top of the square to remove it, and then click on the lower I area to turn it on.
Note that you can also select multiple buttons or textfields at one time to change them all at the same time.

How do I prevent the menu bar from moving down when my popover is open?

I have an app with a popover that appears on a status bar item. The thing is, when you click on the icon while you're in a full screen app, then move the mouse away from the menu bar to click on something in the popup, the menu bar moves up, and so does the popup. It's annoying.
Anyone know of any way to solve this? I've tried attaching an invisible menu to the popup, but I can't get the menu to be invisible.
Screenshot for clarity, the annoying part is where I wave my mouse around:
The popover window is moving because its parent window is the status item window, and when the parent window moves, the child moves with it. (Before I investigated this, I didn't even know Cocoa had parent and child windows.) I solved the problem with this code immediately after showing the popover:
NSWindow *popoverWindow = self.popup.contentViewController.view.window;
[popoverWindow.parentWindow removeChildWindow:popoverWindow];
Now, the menu bar still moves up, but at least the popup stays in the same place.
Either use Carbon events or watch for things happening to the menu bar (window of type NSStatusBarWindow):
Notifications of type
NSWindowDidChangeOcclusionStateNotification
NSWindowDidMoveNotification
NSWindowWillCloseNotification
NSWindowDidCloseNotification
with an object of class NSStatusBarWindow should give you enough information about the menu bar showing or hiding to add proper handling.
Super-hacky approach:
Custom window with some super-high window level to make it appear over the menu bar, then add a transparent custom view to the new window that catches and handles/blocks mouse clicks according to your needs.
Or:
Get the window instance the popover is using to display and track/handle NSWindowWillMoveNotification / NSWindowDidMoveNotification.
I converted #tbodt's answer to Swift 4 and confirmed that is resolves this issue:
let popoverWindow = popup.contentViewController.view.window as? NSWindow
popoverWindow?.parent?.removeChildWindow(popoverWindow!)

Mavericks and NSStatusItem's custom view with multiple monitors

Since Mavericks each screen has its own status bar. This also means that an application running in the status bar (using NSStatusItem) theoretically has multiple NSStatusItem objects associated. In practice, although the user might see multiple "instances" of your NSStatusItem, it's just one (I've tested this). Now the following problem occurs when you're working with a custom view in your status icon: when the user clicks the status icon, I programmatically "highlight" it using the drawStatusBarBackgroundInRect method. The problem is that each "instance" of the status icon (one per screen) is highlighted although the user just clicked one. This behavior is different from a status icon without a custom view. Is there a way to implement this correctly?
For a good example just click on the Dropbox status icon when you're using multiple displays. You'll notice the selection of the icon on the other screen too.
The response from Apple from mentioned by JLinX Apple Dev Forums' thread:
Status Items with multiple menu bars
10.9 introduces multiple menu bars, each of which draws the status items. If your status item has a custom view, this view is positioned
in one menu bar, and other menu bars get a “clone”, which looks
identical. The clones are not exposed in the API. The clones are
drawn by redirecting your custom view’s drawing into another window.
This means that your status item should not make assumptions about the
drawing destination. For example, it should not assume that a call to
drawRect: is destined for the view’s window, or that the resolution of
the drawing destination matches the resolution of the status item’s
screen. You must also not assume that the status item is on any
particular display, except as described below. The clones are only
redrawn in NSDefaultRunLoopMode. This allows the status item to limit
highlighting to one display, by driving the run loop in another mode,
such as NSEventTrackingRunLoopMode. For example, if you wish to
simulate a menu, you would implement mouseDown: to show your window,
and run the run loop in NSEventTrackingRunLoopMode until you determine
that the window should be dismissed. While the run loop is in this
mode, only the true status item will redraw. Clone status items will
not redraw, and therefore they will not show any highlight applied to
the true status item. When a clone status item is clicked, the clone
exchanges locations with the true status item. This means that the
location and screen of the status item window is reliable from within
mouseDown:. You can access this information from your custom view, for
example, using [[view window] screen] to position a window on the same
screen as the status item.
You question is discussed here. Try to draw your custom view in a run loop other than the default run loop to differentiate between screens...
Alternatively, you can just draw the selection in your view instead of talking to the status item.
- (void)drawRect:(NSRect)dirtyRect
{
if( active )
{
[[NSColor selectedMenuItemColor] set];
NSRectFill(self.bounds);
}
}
this will draw across both your view and the clone.

Weird animations when navigating through views or reloading table view contents

I'm currently working on a MonoTouch application with a NavigationController, a root view with some ImageViews in it and some standard and customized/subclassed TableViews and TableViewCells. Some elements are located in xib files, others are code only.
Navigation and table contents itself work fine. However, I suffer some weird "animation" effects... I'm trying my best to describe them as good as possible.
1)
When navigating back and forth on the navigation stack, each time a view appears, it looks like the items of that view are re-layouted. When navigating from a subview back to the root view, it's ImageViews start off at some location where they shouldn't be and slide to the right location.
2)
TableViewCells "unfold/reveal" their content from top to bottom when appearing in the visible area, even when reloading without animation:
TableView.ReloadSections(new NSIndexSet(1), UITableViewRowAnimation.None);
Scrolling down the table, each cell seems to trigger it's own "unfolding" animation separately as soon as it becomes visible.
3)
Scroll bars of TableViews slide from view to view.
For example, when tapping a cell that pushes another TableView on the stack:
- Parent table slides out to the left / sub-table slides in from the right (as it should)
- When sub-table has fully appeared, it's visible cells "unfold" from top (of the table) to bottom
- Finally, when this weird cell unfolding has finished, the scroll bar slides in from the left (where the parent table "is") to it's correct location on the right side. So it looks like it is reusing the scroll bar of the parent table.
4)
When displaying the network activity indicator...
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
... it appears where the network carrier name is (left-most on the status bar) and slides to it's intended location (next to signal strength indicator). The same happens to the "You are being located" arrow. When starting a LocationManager, the arrow appears on the carrier name and slides to the right.
All this animation and slide action is really irritating and distracting.
I checked on some other MonoTouch apps on the AppStore, none are suffering from this.
What have I done wrong with my application?
I'm really grateful for hints on what might cause this weird behavior and how to disable it.
I had this just today - I'd performed some animations in my app using
UIView.BeginAnimations("AnimationName");
UIView.SetAnimationDuration(0.5f);
// and so on...
and it turns out I hadn't actually committed my animations (using:
UIView.CommitAnimations();
ensuring I had called CommitAnimations() got rid of this behaviour!

Resources