I'm working on the app that displays svg icons inside NSCollectionView. I want to implement drag&drop feature to allow users drags svg to Finder or another app. There are I have two questions:
1.) To implement drag to another app I'm using NSFilenamesPboardType for registerForDraggedTypes and in collectionView:writeItemsAtIndexes:toPasteboard: create temp file and write it URL to [pasteboard writeObjects:#[fileURL]]; because collectionView:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAtIndexes:not called in this case. Is it correct implementation? I cannot find how to implement drag&drop for svg in another way.
2.) How I can receive callback that drop ended? NSTableView in data source has method tableView:draggingSession:endedAtPoint:operation which determines end of drag. For NSCollectionView this method not documented, but exist in NSCollectionViewDelegate. Can I use it and app will pass the review?
Thanks for any advice
There is an NSCollectionViewDelegate method that was available with 10.7:
- collectionView:draggingSession:endedAtPoint:dragOperation:
It calls the method AFTER the item is dropped to receiving application.
collectionView:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAtIndexes: will be called if you use NSFilesPromisePboardType. You create the files after the drop. If the other application doesn't accept promised files, this won't work.
It looks like Apple forgot to add the new drag and drop delegate methods of 10.7 to the documentation of NSCollectionViewDelegate. You can use them.
Related
I am trying to implement drag and drop to create a grammatical exercise in which you have to complete the sentence with the right word, dragging the right answer in the right spot (as shown in figure below).
I tried to achieve that by using custom renderer, creating some extended native views that override the methods to implement their dragging and dropping (like OnTouchEvent for Android, and TouchesBegan, TouchesMoved, TouchesEnded for iOS). In both platform I am able to drag the custom native views, but only in iOS I am able to drop them into the specific destination view that I want. In Android it seems to be a conflict with Xamarin Forms view coordinates and the native Android coordinates used in the android custom renderer. Even if I try to "adjust" them, (by manually inserting the coordinates that I want the view to be dropped in) it seems like that the check if(destinationRect.Contains(myTouchX, myTouchY) doesn't work proper.
Git repository example here: Git example
Does anyone know how to solve that?
Or does anyone know how to implement drag and drop (with a proper dropzone to check) in any other easiest way?
In Android, it provide the View.StartDrag(ClipData, View+DragShadowBuilder, Object, Int32) Method method to start a drag and drop operation.
You could check the MS document.
View.StartDrag(ClipData, View+DragShadowBuilder, Object, Int32) Method:
https://learn.microsoft.com/en-us/dotnet/api/android.views.view.startdrag?view=xamarin-android-sdk-9
View.StartDragAndDrop(ClipData, View+DragShadowBuilder, Object, Int32) Method:
https://learn.microsoft.com/en-us/dotnet/api/android.views.view.startdraganddrop?view=xamarin-android-sdk-9
Based on my search, this blog would be helpful for this method.
https://pumpingco.de/blog/adding-drag-and-drop-to-your-android-application-with-xamarin/
You could download the source file from the GitHub.
https://github.com/Pumpingcode/Xamarin-DragAndDropDemo
The documentation just isn't helping me figure out what to do. I'm using Swift 4 and here is what I want to be able to do
When user hits the Save/Export button, save the photo to the photo
library
In code, hold onto that image and pass it back to another
view controller
I can't find in your documentation for iOS/Swift exactly how that image is held, what UIIMage or UIIMageView is pointing to it? If you can answer with some specific code that would be very helpful.
I can't see purchasing or licensing your product without this assistance
To do either of your points, you can register the view controller that presents the PhotoEditor SDKs PhotoEditViewController as the editors delegate. Afterwards, the editor will notify your view controller upon export via the photoEditViewController(_:didSave:and:) method described in our docs.
The exported image is passed within the image argument and you can do whatever you want with it. Either save it to the iOS library or pass it around your app hierarchy.
I hope this clears things up for you!
I have a single-view application open. I need to have two storyboard views (UIViewControllers), because one is a Table View, but when one of the Table View elements is selected it brings up another screen with a normal UIViewController. Is there any way of creating a second storyboard view (UIViewController)?
Of course! Those templates Xcode provides are in no way "set-in-stone". When Xcode created your Single-View Template, it just gave you a base for creating something more. You can create additional classes, view controllers, views, and resources (other than what Xcode starts you off with in a few ways).
To add another View Controller to your Storyboard, just drag and drop one from the Object Library:
It seems like you do not have a basic understanding of using or developing with Xcode. I would recommend reading over all of Apple's documentation on Xcode before going any further. The Building A User Interface section may be of particular interest to you.
I'm have done some development on iOS using Storyboards. Now I'm building on app for Mac OS X and it seems that an equivalent for Storyboards does not exists.
For instance, I'm need to build some kind of wizard, which contains four different windows or views (step 1 to 4).
Currently I've created one Window xib (the standard MainMenu.xib), containing a window with the first view, and three other custom views. Using this approach, I can create outlets and actions, making me able to change the contentView of my window, e.g. when clicking an button. This seems as a fair solution, and my views are all grouped cleanly inside a single xib. But this also cause that the logic for all the view should be handled by the same File's Owner, right? For instance saving the settings on each step and controlling the interaction between the different views.
How is the preferred way to handle a situation like this? Should I instead create four different windows, and maybe in four different xib-files? If you know an sample project somewhere from the internet showing how to handle multiple windows, please give me a hint.
You can make use of the NSViewController class for this purpose. Each view controller will be responsible of loading a xib associated with it and all logic associated with the views can go inside the controllers (Same as in iOS). The MainMenu.xib can now load appropriate views after initialising the required view controllers.
Here is a sample app for your reference.
https://developer.apple.com/library/mac/samplecode/ViewController/Introduction/Intro.html
In xcode, go to File->New->New File
Add an objective C class and set it to subclass of "NSViewController".
This will itself create yourController.h, yourController.m and yourController.xib.
Now you can keep your view and its controller class seperate.
I have created my first application in MonoDevelop. I'm having difficulty to create a second window (form).
If I create a new UIView it has .cs and .designer.cs files attached to it. It looks good, but it doesn't have appdelegate to attach events to.
If I use the new UIWindow I don't have .cs and .designer.cs files attached to it. And I don't have delegates either.
If I copy the original MainWindow and rename it, it almost works, I have delegate and .designer.cs but it complains about duplicating certain objects. Like "Window", "AppDelegate"
So how am I supposed to create some new forms that needs some buttons and events to deal with?
In an iPhone app, you should generally only have 1 window.
Create a new UIViewController with your desired elements, and present it as a "modal" view controller over your other controllers. It will function similar to ShowDialog(), except it won't be a blocking call.
The methods are PresentModalViewController() and DismissModalViewControllerAnimated().
Here is a decent example.