I'm developing a iPad app which is just a series of pictures, and I'm stuck. I've managed to link up a Tab Bar Contoller to the 6 View Controllers and all seems to work well. But I'd like to be able swipe to the next View Controller once the user has selected the button. How do I do this? The swipe gestures don't work for me. Here's a snapshot:
I think you are looking for UIPageController. This is the control that is used in the iPhone Weather app to allow you to swipe from city to city. Go here to see the full documentation on the control.
That's not usually how Tab Bars work in iOS, but…
What it sounds like you're after is either a UIScrollView with paging enabled (keep in mind you'll have to set the scroll view's ContentSize) or a UIPageViewController (if you don't want to deal with sizing explicitly and you're OK making a new UIViewController to house each image). I'd recommend the first option. The process would go something like:
Add the UIScrollView as a subview of your main view (remember, ensure to set pagingEnabled to YES
Add each image to the scroll view
Set the scroll view's content size to the total width of all images
Thanks for the clarification!
Related
I am trying to build an iOS app that will have the structure of Facebook's feed:
A vertical collection view that will have cells. Each cell will consist of image and text.
In fact, I am building my app with the help of this video by LetsBuildThatApp (this guy rocks by the way).
Currently, I am able to touch the image and animate it to full width, and also pan to dismiss it if velocity on Y-axis is more than a specific threshold.
What I want to achieve after that is to also be able to pinch/double tap to zoom. Like this:
I searched around and found some great articles on how to use UISCrollView to zoom. [Article1, Article2].
The problem is that I use autolayout to perform animations but these articles either use Storyboards or frames to position the image in the center of the scroll view [or at least this is how I understand it]. And also they don't involve any animations to start with.
Also, I don't want to present or push a view controller onto the navigation controller stack. I would rather animate the view on top of the base view as I do now.
Any idea on how to achieve this?
Thank you in advance!
I have implemented to a page to display multiple Viewcontroller via UIPageViewController. User can scroll horizontally to view a different ViewController (And I have dynamic number of VCs, depending on the data loaded from server) .
The problem is most of the user does not know that they can scroll horizontally . I would like to show to user when they come to my app first time that the page is horizontally scrollable. Just like the screenshot below
The easiest way is to show them the half-page scroll first so they realize that this page is scrollable. But I have searched through SO and found none of the solution. If I add gesture programmatically, the app might got rejected from appstore. So are there any easy way to do this?
Currently building a store app. I have a collection view that displays clothing images with their prices and title. I'd like users to be able to filter and refine results and change the layout of the page using a special bar that will slide down and plot itself just underneath the UINavBar.
This is what I want to do:
User starts to scroll down.
Slide down nav bar sized custom view at desired speed from behind UINavBar.
User starts to scroll back up
Slide up nav bar sized custom view at desired speed from behind UINavBar.
Custom view should be opaque
Custom view shouldn't effect the controller view and sit on top of it when visible.
Part of my hierarchy:
UINavigationController -> UIViewController -> UICollectionViewController
All above will be taking place in my UICollectionViewController.
Futher info:
Since this is something I'd be doing often I'd like to learn and understand how to do this properly, however I don't mind using ready made solutions.
Image below may help..
I look forward to you responses.
Kind regards
Adding a basic pull down here is very easy steps.
I have used here in this example a UIToolbar to slide in & out
UPDATED
The video mentioned here is updated today with added colours to the slideIn toolbar.
UPDATED : 1
kindly try the GTScrollNavigationBar as described here in this post of stackOverflow.
Another option could be to add a UIPanGestureRecognizer on the scroll view. You could use the translationInView method to know how much distance to move your view.
First, it would be better that you change your view hierarchy to
UINavigationController -> UIViewController-> UICollectionView & custom view
In your current code, have you added the collection view as a cell in the tableview?
Well, since the collection view is inherently scrollable, this is not necessary.
besides, if you add your custom view to the tableview or the collection view, the custom view will scroll alongside with the scrollable view, which, i bet, is not what you want.
so what you may do is to:
1. add the `custom view` to the view of the `UIViewController`
2. add also the `collection view` to the `UIViewController`
3. implement `UICollectionViewDelegate`, `UICollectionViewDataSource` for the `UIViewController`
4. implement 'scrollViewDidScroll' in 'UIScrollViewDelegate' for the `UIViewController` to detect scroll action
5. get scroll direction as indicated here:
Finding the direction of scrolling in a UIScrollView?
6. when a scroll is detected, set the desired frame of your custom view in [UIView animateWithDuration:animations:], and adjust speed by adjusting the duration of the animation.
7. Done!
well, just in case.... you can set the origin of the frame as negative to move the custom view outside the view of the UIViewController
I am quite new to xcode.
I am trying to create a contact details form for an iPhone using the storyboard. The problem is that form is longer than the display and I can't work out how to design it using the storyboard.
Any ideas?
Tom
In IB, you can set the controller's size in Simulated Metrics to Freeform, then select the view and make it as tall as you want. Then, add a scroll view to take up the whole view, and add your UIElements, and lay them out how you want. When you run the app, the view controller will still only be as big as the screen (obviously), but the scroll view will be as big as you made the view in IB (you may need to increase its contentSize even more to be able to scroll to the bottom).
Such forms are often made in storyboards using a UITableView and setting the "content" of the table to be "Static Cells." You can set any number of cells and the contents of the cell you want. The table itself is scrollable inside the storyboard/Interface Builder editor and looks much the way it would when presented to a user.
First, select the tableView on the left
Then, you can move it simply scrolling (on mac, two fingers on the trackpad, or using the mouse wheel)
You should have a look at UIScrollView, it is designed to support content larger than screen size (like you see in web browser or settings)
Basic usage is:
//Set a size which will be able to cover all form elements
[yourScrollView setContentSize:CGSizeMake()];
//Your scrollView now extends from CGPoint 0,0 to contentSize.width,contentSize.height.
//Your subviews should be positioned according to scrollview's bounds not the viewcontroller.view or any other container view.
//Add all the form elements
[yourScrollView addSubview:...];
[yourScrollView setDelegate:self]; //If you need actions after user scrolled etc.
Have a look at the developer manual for more info. Most method names are quite self explanatory.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html
I have a simple app that has a set of coloured views, one red, one green and one blue.
I am trying to make it so that when a swipe gesture is made the current view will switch to the next one in the list in a fluid manner, it looks like moving a long piece of paper with different colours on it.
Is there a way to do this (CoreAnimation)?
You could first look into UIScrollView. It seems to me that what you are trying to accomplish is the same you have, say, in Mobile Safari on an iPhone, when you show all your current pages and can go from one to the next by scrolling. This tutorial is particularly close to what you describe.
If you are looking into more advanced kind of transformations, than Core Animation would be the option.
Actually, nothing prevents using both approaches, UIScrollView to handle the swipe, Core Animation to add more animation to the pack...
You could use a UIScrollView to accomplish this. Add all of your colored views as subviews to the scroll view. Make sure your contentSize is setup appropriately and optionally setup paging to make the scrolling always snap to a certain border. See the scroll view programming guide for more info Scroll View Programming Guide