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
Related
In my storyboard I have a UITableView and above the dynamic cells I added a UIView to keep there a photo and some labels.
Currently, I want to apply constraints to the photo so that it reaches the top, left and right side of the screen and keeps the aspect ratio. However, the storyboard looks like this:
The constraints for photo are:
However, as you see, the constraints are marked in red and when I run the app the photo is not stretched properly.
What is causing this issue?
I would probably do this programmatically. It is pretty simple to create a custom view and set it as your header view. You can either create a UIView with a UIImageView inside of viewForHeader or by assigning it to the entire table with tableView.tableHeaderView = headerView.
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.
I've an instance of UIPageViewController in my project with an iPhone picture showing different sceneries as user scrolls.
I want a "fixed-background scrolling layout" i.e when the user scrolls, the iPhone-picture should remain fixed but only the sceneries inside it should change. How could I do that?
For example: In https://sdslabs.co/#muzi, as you scroll down the Mac-picture is fixed but the picture inside it changes.
Another example can be seen in the 'Numerous' iOS app.
I am assuming that you know how to implement UIPageViewController. I am just explaining how to design your Layout to achieve this.
In your FirstViewController's View add a UIImageView containing iPhone's background in which your images will change on scrolling. Add another UIView as a sibling of your UIImageView and add ContainerView in it. Your PageViewController will be embedded in your Container View.
In shorts, my desired screen layout is basically a user profile (iOS 7 + Xcode 5). I used UIScrollView as the top level view. The reason is that I want all its subviews to scroll (user info view - the view with a profile image and some buttons you see on the screen, and the photos collection view - the one with black background) when it is scrolled.
The region with black background will show user photos. I'm wondering if I could use a UICollectionView here, or there's a better way to implement it. The UICollectionView in this case shouldn't be able to scroll itself, it just shows all cells, while the scrolling work is handled by the outermost UIScrollView.
I read following posts:
UICollectionView inside of UIScrollView
UICollectionView in UIScrollView -> Scroll Order
iOS 7 Collection View inside Scroll View
Some said it's not possible (or at least, weird) implemeting UICollectionView inside UIScrollView because UIScrollView is UICollectionView's superclass which leads to unexpected behaviour. Some said it should be implemented in another way (but I didn't see a clear suggestion).
Yes, you can put a UICollectionView inside a UIScrollView. iOS has fully supported nested scroll views since iOS 3.0, and UICollectionView is a subclass of UIScrollView. For example, check out the App Store app on your iOS device. The screen scrolls vertically - it's either a UIScrollView or a UITableView (which is itself a subclass of UIScrollView). And each row of icons scrolls horizontally - each row is a UICollectionView.
However, it's not clear why you need to put a collection view inside a scroll view. It sounds like you only want the photos view to scroll, so just make the photos view be a collection view. Why do you need to put the collection view inside a scroll view?
UPDATE
Just use a collection view. Set the header of section 0 to the profile info view. You don't need a scroll view.
If you put all the photos in one section, you can set up the header in your storyboard with no code. If you use multiple sections, you'll need to implement collectionView:layout:referenceSizeForHeaderInSection: in your delegate and collectionView:viewForSupplementaryElementOfKind:atIndexPath: in your data source.
I have a set of pictures organized by name like below which indicates where a photo should be in the view:
Image_PPRRCC.png
PP: Page No. of photo
RR: Row of photo
CC: Column of photo
The app has three kind of views as below.
1- View the whole page. Scroll horizontally to view next page.
2- Single image view. When user has double tapped on a picture in whole page view. Scroll horizontally to next photo.
3- View a row of photos. When device is in landscape mode. Scroll vertically to view next row and scroll horizontally to view next page.
I tried using a UICollectionViewController and put the images in dynamically sized cells sorted by their names. The problem was with horizontal scrolling. When horizontal scrolling is selected the items are populated vertically in a UICollectionView and the sorted array of image names and position of each photo in row and column of a page is messed up.
Then tried to use a UIPageViewController with a UIView for each page with a UICollectionView in each page to show images of corresponding page. But I couldn't manage to setup the views for it.
So any suggestions how to setup the views? Which method is better for the desired interface of the app? The one UICollectionViewController method or UIPageViewController method? Or maybe a better method?
use #property (nonatomic) UICollectionViewScrollDirection scrollDirection;
The grid layout scrolls along one axis only, either horizontally or vertically. For the non scrolling axis, the width of the collection view in that dimension serves as starting width of the content.
read more about UICollectionViewFlowLayout in https://developer.apple.com/library/ios/documentation/uikit/reference/UICollectionViewFlowLayout_class/Reference/Reference.html#//apple_ref/doc/uid/TP40012182-CH1-DontLinkElementID_4