I am using a WebView to display some incoming content to users in a single-window application.
There is a single window controller in the app delegate that I use to send -showWindow: on -applicationDidFinishLaunching: and -applicationShouldHandleReopen:hasVisibleWindows: notifications.
This works well until I close the window and click the dock icon to reopen the window.
At this point the web view is blank and no longer responds to mouse input, such as the scroll wheel. The scroll view still indicates the apparent size of the document.
The window is not released on close, according to IB.
Am I missing something with regards to keeping that content around?
According to the documentation WebView is closed with window. However, we can subclass WebView and override shouldCloseWithWindow and return NO.
- (BOOL)shouldCloseWithWindow
Related
I need to scroll to top the main Interface Controller of an Apple Watch app programmatically after each launch specially if users has left the app after scrolling it down.
EDIT:
This is now possible in watchOS 4. Just use the scrollToObject:atScrollPosition:animated: method.
Unfortunately, this isn't currently possible. WatchKit only provides a method to scroll to the top of a WKInterfaceTable, not an entire interface controller.
The only workaround I've found is to hide every element in the interface controller. This doesn't just hide the element, it completely removes it from the controller. Then when you unhide everything, you'll be back at the top of your content.
I'm making app with using Xamarin.forms.
I wanted to know if there is top window or view for Xamarin.forms.
I want to put something like a alert or indicator so that it remain on top depth all the time until it's gone. (even if new page is pushed.)
I can't find any view or window on XF.
Should I use each native window?
Thanks.
You can try to use Application.Current.MainPage.DisplayAlert method to display alert from the MainPage (which ordinary always exists in app).
I have been making iOS apps for a while now and I decided that I wanted to start working on making some of them for the Mac too.
The question I have is this: is there any need for an NSWindow, now that developing for the Mac is so similar to iOS??
So I made a simple cocoa application using Xcode and its comes with a storyboard called "Main", just like on iOS.
In that storyboard file, there is a NSWindow which then links to a NSViewController.
Can I get rid of that NSWindow? As I tried setting the NSViewController as the "Initial Controller" and the app still works fine. So whats the point of the NSWindow?
Also, what class links to the NSWindow? I was trying to blur that background of the NSWindow, but I have no way of linking code to the NSWindow.
Sorry for my stupid questions, but I am completely new to development for OS X.
Thanks for your time, Dan.
Those are many questions in one question:
Can I get rid of NSwindow? No, you need a window to show you views.
What is the point of the NSWindow? NSWindow is needed as the window in which the views are displayed and your events are going up the responder chain.
What class is linked to NSWindow? Obviously the NSWindow class, but that is not what you want to know. I think you want to know the delegate that controls NSWindow. This is NSWindowController, although for the MainMenu.xib it is NSAppDelegate.
Hope this gives you the answers you need. An example for working with views in a window is given in this question.
Please, see for further details the windows programming guide, which states:
The NSWindow class defines objects that manage and coordinate the
windows an application displays on the screen. A single NSWindow
object corresponds to at most one onscreen window. The two principal
functions of an NSWindow object are to provide an area in which NSView
objects can be placed and to accept and distribute, to the appropriate
views, events the user instigates through actions with the mouse and
keyboard.
For the question: Can I get rid of NSwindow? I have further comments. In most cases, You need a NSWindow to show view on screen; but in special case you don't, for example, a popup view when you click a NSStatusItem.
So my answer is whenever you need to respond window event such as min/max, you need NSWindow as the view container.
My app has a NSView in a NSWindow which covers the screen and draws a semi-transparent shade on it, above that I've got another NSWindow which contains my app's UI, so the full screen view is designed to fade out background distraction of other windows.
How can I allow mouse clicks on the full screen view to go straight through to the underlying window, which will belong to another app, or even the desktop? Note that I don't want it to keep focus on my app.
Shady by Matt Gemmell does exactly the same, take a look at the source:
http://instinctivecode.com/shady/
It does this by sending the following message to the window:
[window setIgnoresMouseEvents:YES];
Is there a way to have a single full-screen picture load when the cocoa app is launched? What I mean by that is a full-screen picture, without the menus and stuff that cocoa automatically attaches to apps.( For example, I want to build an app that when the user clicks it - it brings up a picture of say, a zombie, completely full screen - kind of like the end of that maze game.)
While I'm not aware of any maze games that feature a zombie at the end (though I imagine it would be a great companion to Plants vs. Zombies), you can achieve your goal by using NSView's built-in full-screen method -enterFullScreenMode:withOptions: and exit with -exitFullScreenModeWithOptions:.
To enter full screen at launch, just use the NSApplicationDelegate method -applicationDidFinishLaunching:.
As for UI arrangement, I'd just open MainMenu.xib in Interface Builder and delete the window, then drag an NSView ("Custom View") or just a NSImageView into the IB document and open it up. Create an outlet to the view in your app delegate / app controller and connect it to the view.