Nested UIScrollView-iPhone photos application - iphone

I have been facing the same nested UIScrollView problem for long time.I tried some open source codes like Scrolling madness ,three-20 and others but all fails finaly.I am trying to make a photo Viewer application same as iPhone.For that I have created the structure like this:-
1)one View controller.
2)on view of view controller one UIScrollView (i.e inner/parent scroll view) as a child.
3)on inner/parent scroll view number of child scroll views(i.e. outer/child scroll views) ,each represents one page of photos application.
4)On each scroll view one image View on which i am displaying my image.
So what I want is when user scrolls the outer scroll view it should scroll horizontally with all the child views so I will get the look and feel of paging in photos application.Also when user is on one specific image(i.e. child/outer scroll view) he should be able to zoom in/out,swipes and perform single/double tapping.I was able to make it work in sdk 2.1,but it dosnt work since sdk 3.0.Please tell me the idea behind your project.Means which scroll view you are subclassing ,in which view to detect touches.How this completely child - parent relation should be.
If possible provide any sample code also.

There is a WWDC session from 2010 that deals with this very issue.
Here's the short of it:
You need a single scroll view that is paginated and scrolls horizontally. Each "page" of that scroll view is another scroll view containing a photo.

First, it looks like you want to subclass UIScrollView? Every interaction method you need is provided for you in either the delegate callbacks or the touch methods. (Many of Apple's more advanced classes, such as UIScrollView, react poorly to subclassing.)
Second, it sounds like you have a first responder problem. IOW, your innermost scrollview isn't getting the first crack at the touch events.
Andrew

I also struggled with this for a long time trying samples you mentioned. I could finally figure it out with the samples provided by apple (iphone dev center).
http://developer.apple.com/iphone/library/samplecode/Scrolling/Introduction/Intro.html
http://developer.apple.com/iphone/library/samplecode/ScrollViewSuite/Introduction/Intro.html
The first one is pretty basic and probably what u already have. The second one is all about zooming, etc. Just study these and the samples you already have, I think you will be able to figure it out. On specific topics just come back here search for answers or post another question.
EDIT: I forgot this one check out these examples by Andrey Tarantsov hosted on github. This is what you want... http://github.com/andreyvit/ScrollingMadness

Related

Swift Instagram's profile view with its exact behaviour

I have a problem where I have to create a view as similar as instagram's profile view. I have managed to get very close by digging into many solutions and I think I have found the best one for the purpose. I just need to get the final touch to resemble Instagram's profile view completely and I can't find the solution.
I leave the complete source code here so you can keep up with me: https://github.com/eduasinco/ProfileView
When you look at the project you will see a headerView on top of all other views, I have set the view of this header to be a PassthroughView which means that every action on that view will be ignored and pass to the next in the responder chain which in this case is one of the scroll views behind.
So far so good, nevertheless there is a small nuance, inside the header view there is a segmentControlView which is in charge of switching the pages, if you touch that segment control it will change pages just fine, the problem comes when you try to scroll the view from the segmentControlView it wont work. I would like to make this scroll behaviour happen as similar as Instagram's profile view.
To sum up, I would like to have a way to make segmentControlView work as it is doing now but also be able to scroll from it in the same way you can scroll when you are touching any other place inside the header view.
I have also tried all kinds of touch overriding but none of them works.
Any help will be appreciated

How to lock a view as the user scrolls

I am new-ish to iphone development and I am trying to figure out how I can fix a view after it has reached a the top of the screen when a user scrolls a window. Then the view would unlock when the window is scrolled down again to go back to its original position. Ive seen this on on a few apps like instagram (with the user name separators).
Does this design pattern have a specific name?
An example (not iPhone though) can be seen on http://mashable.com/ -- Look at "The New Stuff", "The Next Big Thing", and "What's Hot" bar. See how it locks as you scroll down
My solution for you is
create a UITableView
create a UIView separately which will be used as fixed table header
setup the table's tableHeaderView property to conform the UIView's frame
as UITableView is inherited from UIScrollView you can rely on scrollViewDidScroll method in which I properly adjust my fixed header as Y coordinate changes when scrolling the table.
There can be other similar solution for this too but a strenght of this particular solution is that you can manipulate the fixed header's gui element throughout the scrolling easily.
An example is always better than writing down the details so I created for you (and hopefully for others here at SO) a sample project (of course quick'n dirty), which you can find here at github:
https://github.com/codedad/SO_Fixed_TableHeader_iOS
If I'm correct, you're trying to achieve something like the UITableView in the Contacts app?
It uses the sections of the UITableView for the sorted letters and displays them always on top.
Have a look a this question and create custom section headers.

UIScrollViews and Dynamically Creating Pages

I want to be able to dynamically populate UIScrollView. Like how it is done for row views in UITableView. I have a class that takes in some parameters and creates the respective view when it scrolls. Currently I have 8 views.
These 8 views have different background image, image and label according to the page number it is currently in. However the basic skeleton for this view is the same. What i am doing right now is in ViewDidLoad I am creating 8 views and add them as subviews and scroll over.
I don't want to do this. I want to create three views and the rest i want to populate when the user scrolls a page and then a page etc. How do i do this? ANy pointers/tutorial?
First of all you calculate the ContentSize for the scrollview (when you want to use the iPad in landscapemode with 8 pages then the width should be 1024*8 = 8192px and the height 768px).
Then you should implement the UIScrollView Delegate method:
scrollViewDidEndDecelerating:
In this Method you check on which page you currently are with the contentOffset property of the scrollview and start updating your left and right hidden views..
Hope this helps you a bit.
Check the two most recent WWDC videos for two excellent sessions regarding expert use of UIScrollViews. Additionally you can review a brief tutorial here, written by the well known cocoa expert, Matt Gallagher.

Rotating UILabels depending on page in UIScrollView like in Google+ App

I have an application with several (8) different Views in a UIScrollView. They are circling so that you get to the first when you try to get "behind" the last and vice versa.
My problem is how to create a titlebar like in the Stream of the Google+ App. There the titles are circling with the pages and show the current visible page.
How could I realize that? Would it be possible to create a general class to use such a view in many different apps?
I've already tried to solve this problem with some different approaches, but they all didn't work (well). I can display labels above my scrollView and move them, but how far and with which text seems to be difficult for me.
So now I'm looking forward to your answers ;D
Try using two UIScrollView, one for the content and one for the headers. The header UIScrollView would be controlled by your view controller that is also a delegate of the main UIScrollView. Update the header UIScrollView whenever you receive a -scrollViewDidScroll: message from the main UIScrollView.
I think you need to add label in customview and then add customviews in scrollView, you will get events for individual view, so you can rotate that view according to angle and keep label at fix place...

Special UIScrollView with multiple objects (3) on each page

What I want to accomplish is something like this:
Two different scrollViews, and each one scrolls horizontically. Each showing 3 images, and a half one (or 1/3th) piece of the next image in the datasource of the scrollview.
Does anyone know how to accomplish such a scrollview?
I also want to be able to tap an image to flip it and show some information and a button to the detail. (See lower scrollview).
Tapping it again would just show back the image, much like the coverflow ui inside itunes, but without the coverflow being 3D...
Any help is welcome :)
Thanks in advance,
Lewion
Scroll view doesn't have a datasource. What you are looking for is standard scrolling and nothing special.. So it is definitely doable... Check the scrolling and photo scroller sample codes from apple developer samples. For more implementations of scroll view check the scroll view suite sample code and read the scroll view programming guide.
The flip animation is also a standard animation for a view and is easily doable. For example, create a utility application for iphone. It has a flip side view. See how that animation is done.