Swift image slider/carousel UIPageViewController vs Scroll View - ios

I found these examples of doing a images slider/carusel. One using a UIPageViewController and one using a scrollview
In my app I need to embedd a image slider inside a contentview for a VC, then also add click to enlarge to view the image in fullscreen as well. So what are the pros/cons for using a UIPageViewController or a scrollview?
Looking at the two examples they look like they behave the same beside the UIPageViewController showing dots/indicators

I wouldn't recommend using a UIScrollView, (too much work/potential for bugs resetting the scrollView's contentOffset for sliding through the gallery smoothly).
When I've implemented a sliding image gallery before I used a UICollectionView. The collectionViewCell's bounds match the parent collectionView's, the cell contains an imageView pinned to the edges of the cell and the collectionView's scrollDirection is set to horizontal.
You can add a UIPageControl on top of the UICollectionView if you want, it's not necessarily an essential feature. As an alternative to using a UIPageControl I've added a UILabel to float above the screen coordinates of the UICollectionView and update its value based on the number of items and the currently displayed cell in the collectionView. E.g. 1/4 -> 2/4 etc.

Related

Horizontal image list in IOS on top of card

Hi I am trying to achieve this:
Every search gives me a horizontal list that is contained inside the card and every image disappears into the cards border. Any tips on how to achieve this effect?
First of all, I'm not sure if your question is a programming question, but I'm answering your question anyway.
So you could have UICollectionView and each item (row) has another UICollectionView.
Since I prefer UITableView most of the time, I would use UITableView and each row (each UITableViewCell) has a UICollectionView for displaying the horizontal scrolling albums.
The white container in each cells/rows is merely a UIView with constant height and dynamic width (leading and trailing are clipped to the superView with inset, say 10.0). Then the UICollectionView is clipped to the superView (UITableViewCell) with no offset or zero offset/inset.
If for adding shadows to your view with rounded corners, there are multiple ways to achieve that, but I'm giving you a quick link for your reference: https://medium.com/swifty-tim/views-with-rounded-corners-and-shadows-c3adc0085182
I hope this helps!
Put three collection views that that stretch between the card borders. Let the collection views have a transparent background.
Then place the three smaller white views behind the collection views. Give these views a drop shadow.

Scroll horizontally in UITableView - Swift 3, iOS

I need to horizontally scroll through a list of thumbnails at the bottom of the screen that shows all the user's recently taken photos / videos.
I created a UIScrollView with a UITableview inside of it.
Is this the correct approach because I can't seem to find an override method in its superclass for scrolling direction?
Most of the topics I can find online deals with putting a UIscrollview inside a TableCell, which will not work for my specific application?
The hierarchy is:
View > Scroll View > Table View > Table Cel > Content > PhotoThumbnail
Below is a screenshot of what I'm trying to do:
I am not really sure why do you want to use UITableView for horizontal scrolling which lay out there cells in vertical manner. If you want horizontal scrolling I would recommend using UICollectionView where cells can be added horizontally or vertically or both.
Still if you want tableview to be scrollable in horizontal direction I would suggest you to check this project to get inspiration or using it.
https://github.com/alekseyn/EasyTableView
Instead of using UITableView you can use UICollectionView to achieve the desired result i.e, horizontally scrollable cells with imageView and other elements that you need.

Multipage UICollectionView with View

I am trying to create a collection view layout similar to the one used by Twitter and Product Hunt. I want to have a horizontal collection view to tab between data while also maintaining vertical scrolling in the tab I am in. I do not want to just change the datasource that is loaded into the UICollectionView. I have tried several different layouts but none of them have been successful.
Right now, I have a UIViewController with a UICollectionView & UIImageView object inside of it. The UIImageView's size is (3/8) of the UIViewController's frame and begins at (0,0). The UICollectionView's frame is equal to the UIViewController's frame but the cv is offset to be below UIImageView & its size is equal to the size of the UIViewController's view. The (1) cell inside the UICollectionView has a UICollectionView inside of it -- this can be configured with the data you want (multiple cells). This layout works fine for a single datasource.
However, when you want to have multiple datasources accessed by scrolling horizontally the layout breaks down. You have to change the flow layout of the outermost UICollectionView to horizontal. When you do this, you get a layout error because the size of the collection view is larger than than the view and you cannot scroll vertically.
If you reference the image I provided, I think you can infer what the desired layout should behave like. You should be able to access the other datasource by horizontal scrolling but also be able to scroll the current collection view full screen and not have it fixed to the bottom of the UIImageView. I tried adding logic to the scrollview delegate methods but that didn't work either. Thanks]2

Implementing photo slides from ios library like photo app

Does anyone know how to implement a photo slider action sheet in xcode like the photos app? Iv been searching around and couldn't find anything that worked this is ios8 and xcode6 please reference the screen shot below from the photos app
The sideways scrolling mechanism for swiping through photos in the photo picker is a UIScrollview.
What you will want to do is create a UIScrollview within your View, then populate it with the items you wish to scroll through. The way to ensure that it is horizontally scrolled in the Scrollview is to set the width parameter to the width of the total count of items in the Scrollview.
For example, if you create a scrollview with 10 images, you will want to set the scrollview's width property in ViewDidLoad of the main View to (image.width*10).
The most basic way to do this would be:
Set up View, add a Scrollview
In Viewcontroller, create property and assign Viewcontroller as UIScrollview delegate
Instantiate the scrollview in ViewDidLoad
Set width of the Scrollview manually (width of each image * number of images). You may want to add some padding using the built in content inset methods so they aren't directly bordering eachother.
Use the scrollview.addSubView(images) method for all images to be added

Infinity backgroundView in tableView

I have UITableView with background image and then I scroll it I have parallax effect like background imageView scrolls too. Problem is that then my image finished I have tableView background. Is it possible to make infinity imageView? Like then I go through image then starts this one image from beginning.
In next few days I will add lib thay solved it and creates parallax effect under tableView
https://github.com/bizibizi/TableView-Parallax-Background
Can you show me how are you placing that image behind the TableView? I guess the hierarchy in the storyboard should be
UIView -> UIImageView -> UITableView
The size of the UIImageView and the UITableView should be the same. So when you scroll up and down the UITableViewyou could see the image in the background.
But please explain your scenario abit more so that I could suggest you something appropriate.
What Hanny means is that you need to have the tableView on top of imageView ordered in the stack of the parent view's subviews. What you can also do is stack two tableviews on top of each other, and add a touch event that moves both table view's scroll views. The image table view would contain cells that are the size of the whole view frame.

Resources