iOS swiping/paging between detail pages of Collection View Items - ios

I am working on an iOS app using Xcode 10 and Swift 4.2. I have a collection view that has images and once you tap on the image it takes you to a detail page that has the full-sized image, date and saying displayed. The data for these details are stored in an array and passed from the collection view to the detail page. I want to be able to swipe left or right and go to the previous or next item from the collection view as you would in the photos app.
Is there any built-in functionality that allows for easy paging/swiping, or is a programmatic manipulation of the array index the only way to accomplish this task?

I don't know if you are familiar with CocoaPods, but there are plenty that can work for you, for example there is SwiftPhotoGallery, but that just maximizes images and let you swipe right and left as you said.
For the specific functionality you describe I would suggest that in the navigation to the "Detail Page" you sent the whole array too, and just show the index of the item tapped in the collection, your "Detail Page" will be a UICollection as well but with a custom cell that takes the whole space of the screen and with a horizontal flow so you can swipe right and left, if you have this code in your github account or any other repository I'll be willing to help to make my point clearer.

Related

How to use CoreData with two view controllers one of them has collection view

First of all, I am new in coding, so please be patient with me.
My app has two view controller, the first has UICollectionView and the second has UITextField.
I am trying to tap on one of these collection view cells and then it takes me to the second view controller, where I can type in the textView then save it into CoreData. And then when I go back and press on the same cell i get my saved text. Then when i change this text on the ui text view.. it saved automatically.
Can any one give me an example or put me in the right track
The essence of how that might be done is to implement the collectionview delegate and then determine which cell they clicked on, so that the next screen loads/and updates the correct data. After they click you would call the "segue" with some code. The segues are setup in Xcode's visual editor by control click and dragging a line to the second view. (It's weird, there are some great youtube videos out there) The data would be stored in an array. After you update the data, you could dismiss the second view and the collectionview behind it would be visible again.
I would check out chapter 4.5 of the free iBook "App Development with Swift". Chapters 4.5-4.8 would really get your rocking the right path. If that book is too complex then also look into "Intro to App Development with Swift"
I even have some videos to take you through the process, dunno if I have one for 4.5 but if you continue with it, I have one for 4.6.
https://www.youtube.com/watch?v=Q5u9SGhQoPY&t=2254s

Swiping between dynamic UIViews content in IOS swift

I am new to ios and I am trying to find a way of paging through dynamic content.
An example of what I want to achieve is the BBC News app
https://itunes.apple.com/us/app/bbc-news/id364147881?mt=8
The user selects the story from a UItableView and is directed to the detail view.
In the detail view, the user is able to swipe back and forth through the stories instead of going back to the table and choosing another story. I don't really want to make a UIView for every story, since it is difficult to determine how many stories there will be.
I would appreciate if someone could point me to an example of this usage.

UICollectionView for Springboard like folders

I am trying to achieve the following effect:
A UICollectionView displays a grid of cells for a parent type of object, e. g. a photo album. When I tap one of these items, I would like to scroll that element to the top of the screen and open a Springboard like folder from it. Inside that folders area, another collection should be shown, consisting of the detail items, i. e. the individual photos of that album. Tapping in the remaining "parent" view closes the folder again. See this schema:
What I have done so far is a regular collection view for the albums. When I select one, it scrolls to selected item to the top and then uses JWFolders to open an empty folder at that place. Once that is shown, I trigger the surrounding UINavigationController to push my 2nd view controller with the detail items. That one is layed out so it appears to the user as if it were still the same view.
There are several problems with this approach, and I would like to know how to do this better:
JWFolders takes a screenshot and animated two halves of it up/downwards to achieve the opening effect. This is ok, but pretty slow on an iPad3, because it moves a lot of pixels and the iPad3's GPU is not quite up to the task.
The 2nd view needs to be pixel-perfect to match on top of the first one. This is likely to break accidentally.
I am limited as to what animations are possible for the view controller transition. The default UINavigationController's push from the right is not fitting. I override that to do a cross-dissolve, but still it is far from ideal.
I would like to get pointers as to how to approach this problem in a maintainable manner that does not require to much creative hacking against what the frameworks are designed to do. I might be missing something obvious here, so pointers to examples or general advice are appreciated.
Update:
I changed the approach a bit. Now I use a container view controller that has two embedded collection view controllers. One for the "Album" and one for the "Photos" part at the bottom. Using a UIImageView in the middle between the two I can get the triangle pointing upward done. This is also nice from a maintenance point of view, because it makes maintenance easier with the two collections being handled completely separately.
The app uses Auto Layout, so I can change the amount of space each of the two embedded views takes by modifying the constraints. This is way faster than the screenshot based approach with JWFolders and works nicely on an iPad3 as well.
This almost gets me where I want to be. The one thing that remains is to get the opening animation right. I would like to simultaneously scroll the Albums collection, so that the tapped item goes to the top and expand the photos collection with the triangle pointing at the Album cell.
Can I somehow "connect" the lower view to that cell via layout constraints, so that the scrollToItemAtIndexPath:atScrollPosition:animated: call drags the lower view open?
To get around it I would lose the library and cause iOS to move those display elements around without screenshots or other tricks. On the tap, cause the tapped icon to retain its normal appearance while you dim all the others. Find the contents of the collection view from the top to the end of the line where the tapped icon is. Create two new collection views - one which contains the top half, including your tapped icon and one containing the rest, below. Animate those views apart to make room for the folder view.
The folder view is another UICollectionView that appears in the gap created.
In the main view there are either one or three views presented depending on whether the drawer is open or closed. I would probably look at creating a view controller with a collection view, and using view controller containment to manage all three views. You have complete control over how those views are presented, so you could animate top and bottom views up and down simultaneously to reveal the folder view in place, as Springboard does.
When that's all working then you could generalize and start doing things like deciding to make the tapped icon part of the bottom collection with the folder appearing above if the icon was low on the screen.
(I hesitate to answer this because of the large number of upvotes yet no answers, so I may have missed something - but that is how I would begin trying to achieve the Springboard effect.)
To solve this problem in a relatively easy way, you could try to make the folder a simple UICollectionView subclass and then insert that cell when the albums cell is tapped.
In the collection views data source you would have to return different size etc. for the folder cell.
In the folder you would have to create the folders collection view, avoid making the folder cell the data source of the cell folder collection view tho.

iOS: UI Ideas for moving items between multi-level tableViews

I am building an iOS app that allows the user to browse a tableView, click a cell, then navigate deeper into another tableView using a navigationController.
I have a requirement to be able to move any of those items/cells to another place in the navigation stack. Right now my idea is, once the user selects the cells to move, to display a modal tableView that will allow the user to navigate through the same structure as before, but this time choose the location (by pressing and holding) to place those cells.
Are there any other UI ideas or clever programatic ideas that anyone might have that could be a better solution to this problem?
Perhaps take a look at how Apple's iOS Mail moves email messages between different mailboxes?
This also basically displays a modal view controller, but it flattens the hierarchy, by indenting nested items below their parent objects. You than just select the item that is the destination.
This of course only works if your hierarchy is not too deep, otherwise it's probably best to do it like you outlined it. The only thing I would perhaps recommend doing in addition, is to also have some sort of visual method (button?) to select the destination. A long press by itself might not be intuitive enough.

iOS sdk printing multiple images

i'm working on my first app and now i'm trying to implement air print in a customised version of the "Autoscroll" Apple sample code. basically i present the user with the print controller from a custom button and then they should have the choice of printing the image they have selected. autoscroll works in this way: you have 2 scroll views in a view controller a big one that allows zooming and a small one that slides in/out by tapping once on the big one. the small scroll view contains a number of thumbnails that are loaded in the big scroll view on selection by tapping. so far by studying the print photo sample code i manage to print one image; the first one loaded when the view controller is presented. i'm aware that multiple ready to print images have to in an array, but the example in the printing and drawing guide has 1 line of code and talks about an array of image views. the images i need to print go inside a scroll view.
thanks in advance for any help.
Xcode as a sample source code that u can use to archive what u want, since it as already some of the features that you want to implement.
The name of the project is ScrollViewSuite and you can download it from here: here

Resources