I would like to reorder my NSTableView rows using drag & drop, but all the examples I have found require the implementation of NSTableViewDataSource. I'm populating my table with bindings, and would prefer to keep it that way. Is it possible to implement NSTableViewDataSource and bindings side-by-side? If so, how?
Yes, you can combine bindings and the drag & drop methods of NSTableViewDataSource. Implement the drag & drop methods and don't implement the data methods. Use the methods of NSArrayController to reorder the data.
Related
I am building an app which enables user to drag a UIView onto another. Currently I have the implementation as a UIScrollView but that does not give me the best experience as to achieve an experience like Apple's drag and drop requires handling of many cases ( including edge cases).
I am curious if this can be done using a UICollectionView. I am looking to drag cells onto another cells after which the cells contents merge and the source cell is removed.
Any idea/ suggestion would be appreciated. I am not sure if adding what I have is neccessary but if needed I can certainly add the code which I have.
Yes, using a collectionView would be a good choice for scrolling and drag/drop. There are many built in methods that support drag and drop.
https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/supporting_drag_and_drop_in_collection_views
Using iOS 11 I'd like a UITableview to support both existing row re-ordering using the standard row drag handle and also accept dropping images via the new UITableViewDropDelegate protocol. Using the standard examples I can accept images using the tableview.dropDelegate working OK,
https://developer.apple.com/documentation/uikit/views_and_controls/table_views/supporting_drag_and_drop_in_table_views?language=objc
but as soon as I assign the dropDelegate, the existing row-reordering no longer works. I tried setting the tableview's dragDelegate and returning an array with single UIDragItem (same doc examples), but this still does not give the existing row re-ordering and the complete cell view can be dragged to "anywhere" in the app, not just in the tableview. Also the animations that show the re-order insertion position do not work.
Any idea if this (combining drag/drop + reorder) is at all possible, or should row re-ordering be handled by the dragDelegate/dropDelegate too? Plus: any example on how to do that?
I have five textFields I want to shuffle the letters from one textField to another.
Let's say I want to replace the letter A by B by drag and drop features. I will drag the A on B & B on A.
I have research this, but it is written in C#
How can I do that in Swift 4? Should I have to use UIPanGesture or something else (libraries).
I doubt if textfield is a correct approach.
I would suggest you to use UICollectionView as it already has the functionality of drag and drop.
Basically you need to have textField in the cells of UICollectionView and implement drag and drop functionality.
You may consider following:
Apple docs
RAReorderableLayout GitHub Library
I am using CHTCollectionViewWaterfallLayout as the layout for my collectionView, since my cells do all have different sizes. But I would also like to implement drag & drop in my collectionView. The libraries I have found would not allow me to implement both at the same time. Is there any way to do this?
Thanks
I found a way to do it, I used one of the existing Drag 'n Drop libraries and made sure it inherited from the CHTCollectionView instead of the UICollectionViewFlowLayout, this worked pretty good! Still some errors to work out, but the beginning is there
I'm writing an app in which there will be user defined "categories" which will consist of a label and each category will have a user defined list of "items" which will be UIButtons. I want a user to be able to layout the user interface to their choosing. What's the best way to implement this? Any example code out there?
Edit: Just to make myself clear, I have groups of buttons with a group "heading". I'd like users to be able to move these buttons around inside a group and also to arrange the groups as a whole. It's okay if they have to enter some sort of "edit mode" to move things around.
Probably the easiest way is to use editable UITableViews with UITableViewStyleGrouped style (just like Settings.app). Then you can add, remove and arrange items inside groups. You can show it as "edit mode" view.
Here are some useful posts about it:
iOS 5: Drag and Drop Between UITableViews
Tutorial on How to drag and drop item from UITableView to UITableView
iPhone UITableView Tutorial: Grouped Table
You could use touch handling methods to enable drag-drop type of rearranging of buttons. UIPanGestureRecognizer is a useful class for this. A reference for this can be found here.