I'm working on a small, OSX app (it's a menubar app). When I initially build/launch the app, it goes to the foreground and all other apps go to the background (as they should). When I click on another app, that app comes forward and my app goes back (as it should), but when I click back on my app, it doesn't come forward again. The other app stays as the front-most app (regardless of what that other app is).
The big problem with this, aside from it just being weird, is that none of the hover actions or cursors work on my app when it is not the frontmost app.
Is there a way to programmatically force it to the front? How come clicking on it doesn't bring it forward?...
I found the answer in this question. It can be done using either this:
[[NSApplication sharedApplication] activateIgnoringOtherApps : YES];
or this:
[[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
Related
I want to have a window in front of all the others apps.
I want this window appear on keyword shortcut like "Alfred" app.
I try a lot of solution but nothing work for having NSWindow in front of fullscreen app on main or second screen.
I tried the classic :
[self.window setLevel:NSMainMenuWindowLevel + 1];
[self.window setCollectionBehavior:NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorFullScreenAuxiliary];
[self.window setHidesOnDeactivate:NO];
It's work except with Fullscreen app.
It's work with NSPanel with [self.videoWindow setStyleMask:NSBorderlessWindowMask];
but only on main screen.
Anyone have a solution ? Alfred developper around ?
Alfred is implemented as an Agent. Agents can display Windows on spaces of fullscreen Apps. You should also make your App an Agent.
This can be achieved by adding the Application is Agent flag to the info.plist file of your App and setting the value to YES.
I managed to disdplay auxiliary window on top of full screen app via the following:
self.collectionBehavior = NSWindowCollectionBehaviorMoveToActiveSpace | NSWindowCollectionBehaviorFullScreenAuxiliary;
do not call [NSApp activateblabla];
make application LSUIElement, and do not display the Dock icon via TransformProcessType
However, don't know yet how to display it correctly for app which has the Dock icon. From the other side I do not know which app can do it while having the Dock icon.
It may depend on exactly how the application in question achieves fullscreen, but you likely just need to use a higher window level than NSMainMenuWindowLevel + 1 such as CGShieldingWindowLevel()+1
You can download Quartz Debug from Apples developer downloads (required free developer account)
Quartz Debug can tell you the level of any window and all you need to do is set your window to be higher than the one you are having problems with (assuming the app in question isnt doing something odd to be fullscreen).
If you have a full screen iOS app and you want to prevent the notification center from being pulled down, can you and how?
Also can you block notification alerts or banners from displaying while your app is loading? (I think this is a no way for sure but wanted to ask just in case.)
It has been my experience that fullscreen apps (statusBarHidden = YES) have a slightly different notification center behavior by default: Swiping down over the area previously occupied by the status bar will only show a little tab. Only swiping the tab will then show the notification center. This has been enough to prevent accidental activation for me so far.
Currently, there is no public API for manipulating the behavior of the notification center. I am of the opinion that it's not likely that an app will ever be able to block a notification's appearance, and only slightly less unlikely that an app would be able to prevent the notification center from appearing. iOS is all about a consistent user experience experience at the price of developer freedom. I could see being frustrated by this kind of functionality if I were an unexpecting user.
All that said, there is always the dark-side of undocumented APIs. I would not be surprised if you could pull off some cleverness using those on a jailbroken device, but that's not my cup-o'-tea.
I just now figured this out. I am developing a game that runs in landscape and whenever I touched the left side, the notification center tab would appear. To fix this, you want to add the following:
setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft
I added this right after I setStatusBarHidden and I no longer have the problem of the notification tab.
Hope that helps.
An API was introduced in iOS 11, alongside a change in behavior to how Notification Center (and Control Center) is presented, to allow you to specify the desired behavior.
UIViewController.preferredScreenEdgesDeferringSystemGestures
In iOS 11+, Notification Center will always pull down when swiping from the very top of the screen, even if the status bar is hidden. preferredScreenEdgesDeferringSystemGestures allows you to specify that swiping a screen edge should not trigger the standard system UI, and instead it will provide a pull-out tab that the user must swipe again to bring out the system UI.
This is intended to be used for games where users swipe frequently, where it would be undesired to bring in system UI instead of control the game. For an immersive app like that, you can return .all to specify you don't want any system UI to appear the first time you swipe any edges of the screen, and it should instead prefer your app's own gestures.
Note that this will disable the ability to swipe once from the bottom to close an app on iPhones and iPads that don't have home buttons - the user will have to swipe twice to close the app.
There is still no way to completely disable Notification Center from within your app, nor prevent notifications from appearing while your app is in the foreground.
I built a very simple code snippet to address this issue programatically. I have a timer set-up in my app delegate that runs every .2 seconds each time it runs it keeps moving the status bar orientation so it doesn't impact the game play. I haven't experienced the annoying notification center in my app since! The only issue is the volume control rotates constantly and might be annoying but it's less annoying than notification center
int tick=0;
-(void)toggleNC
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
tick++;
if (tick==1)
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
}
if (tick==2){
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
}
if (tick==3){
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}
if (tick==4){
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortraitUpsideDown];
tick=0;
}
}
I have a problem which is driving me nuts.
Suppose you have an app with a window that is set to "Visible at Launch". When you launch the app, the window immediatly appears.
If you add this simple app to the login startup items list, when you log in, the app is automatically launched and you have the window just opened in front of you. This is what was happening in Snow Leopard.
If you repeat the same steps in Lion, as soon as you log-in, the app is launched but the window does not appear.. It seems that the NIB doesn't get loaded.
To make it appear you have to click on the app icon in the dock (even if the app is already launched).
This happens even if you specify [NSApp disableRelaunchOnLogin] according to Apple documentation here.
Things become worst if your app has NSUIElement = 0 and therefore it doesn't have neither an icon in the Dock, nor a Menubar. In this case there's no way to make the window to appear.
Is there a way to obtain the expected behavior of Snow Leopard? Am I missing something?
I developed an app for IPhone and it's posted to itunes for approval. Now when I test the app I found out a strange behavior which I think should be rectified. When I launch app first time, the app launched and when I press home button it closes but when I tap the app icon to open it again it opens where it was last closed.
How can I change the view to first view of the app when it's launched after closing by Home screen button?
If you don't want your app to run in the background you need to set the "Application does not run in background" key in the info.plist file. This means that your app will completely restart every time your user returns to it. Take time to decide if this really is the best move for your app. Allowing users to return to where they left off or remembering information about the last session can be a big plus.
If you do not set the info.plist value like I mention above you can manage the way your app behaves by using the: applicationWillEnterForeground: in UIApplicationDelegate or you could observe UIApplicationWillEnterForegroundNotifications. Read up on all the available notifications and methods available for this in the UIApplication Delegate documentation.
(ios 4.2)
When I force quit the application (exit(0);), the application quit, but the iPad "taskbar" doesn't seems to be refresh(app stay on it)
Do you have this behaviour? If no, how did you completely close?
(i know force quit are not "Apple friendly", but it's for a custom app)
Thanks!
Whatever the fate of your app's process is, its icon will always remain on the app switcher, as a "recently-used" app, until the user taps and holds, and removes it using the minus icon. I don't believe there's anything you can do to make iOS not display it there.
The process will already have quit, though, since you told it to exit(0).