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
Related
I am new to Xcode (started a few days ago).
I'm trying to find a way to get a few photos or videos in a display where the user can scroll or tap through as they desire. There will be multiple viewControllers each with a different set of photos.
Is there any existing UI type data types I can just drag and drop to make this work? Or is this out of range of the capabilities for someone not using code specifically.
I know Java, C, C++, MATLAB, etc. but never have toyed with Objective-C until now. Point being, I should be able to follow any logic you can throw at me, but I'm unfamiliar with the GUI and layout of Xcode as a whole.
This is what I currently have.
This is what I want. Perhaps with functionality to tap to full screen the image or swipe to go to another image. (This image was made with photosop. I don't actually have the picture file in Xcode because I don't know how)
SOLVED: Placed desired images in "Supporting files" content folder inside Xcode. This allowed me to select which photo I want displayed in which ImageView. To fix the proportionality issue where photos in Simulator are far too large, I simply added height and width constraints along with some other centering aspects and got the desired result.
Add UICollectionView in your view and set flow of collection view is horizontal make cell size that you want to keep.
Take a look at UICollectionViewController where you can display multiple cells with embedded views for your images, and consider segueing between them via a UINavigationController.
Edit: Now that you've added screenshots, I'd recommend using a UICollectionView embedded on your subclass of a UIViewController instead of a UICollectionViewController. This should give you more flexibility.
I have design the UI for the below screen as I am little bit confuse that what should have to use for the below screen. As you seen the on the screen below things:
1.Scrolling part of Images swap.
2.Again another Scrolling images Swap.
So here for the scrolling Images what should I use its Collection View for both or Pagecontrol for one and Collection view for other. Please suggest me.
Thanks and Appreciate for the help...
Use UITableView and in its cell use UICollectionCell so that you can scroll horizontally and vertically.
see Back image, this is how you can implemented output looked like.
As Tinu Dahiya pointed it correctly, You should use tableView and custom tableViewCells to achieve your UI design. This approach will also make your coding easy to handle dynamic contents which you might be fetching from server. For your reference you can directly use this control from cocoa controls. This control is ready made dish for you, you just have to implement your logic to achieve your functionality.
I was wondering if this nice master-detail transition where you click on the tableView cell and it expand to disclose the detail , with the cell's label being the navigation bar title is an interface which is part of the SDK object library or it is a customised one?
This is a custom transition between ViewControllers.
There's a nice example of a few transitions (including this one) in this library.
Of course you'll need to add the tableview etc' but this is a great place to start.
I've tried few things but so far this is the best option I could think of.
Animating the frames of all the visible cells and making use of childViewController is how I achieved it.
Animation test project
https://github.com/armaluca/iOS-App-Store-Explore-Section-Animation
Would be nice to know any other possible solution and ultimately to know how Apple did it!
It is custom implementation.There is no API in UIKit/UITableView which implements this behaviour. Only animation to present a cell is there(which I think is used here).
This behaviour can be implemented like-
Add sections(News, Productivity, etc) in table with zero cells(numberOfRowsInSection: = 0 for all sections). Then on tapping any section just reload that section(reloadSections:withRowAnimation:) by adding a cell to it(numberOfRowsInSection: = 1) and animation(maybe UITableViewRowAnimationMiddle). Scroll that section/row to top in same animation loop(UI update cycle).
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 want to have a similar functionality like we have with the UITableViewCellReorderControl from the UITableViewCell, but as far as I know I cant use the reordercontrol.
I have implemented Drag & Drop for multiple UITableViews. I can Drag a cell from any TableView to any other. Drag & Drop does work so far. Now I want to push the cells apart when I'm dragging an object over 2 cells, just like Apple does this in Tableviews or when you reorder your apps (the place where you might drop gets empty to indicate the droplocation).
The solutions I thought about are:
1. Insert a placeholder image at the droplocation (this is not so good as I have to sync with CoreData all the time)
2. Change the height of the cell to simulate empty space below it.
I dont think that are the best solutions.