Several UIScrollView Questions - objective-c

I'm a beginner to programming, and I need to make a UIScrollView with paging enabled, but I don't want to make the paging be page by page... I want to make the user scroll and when he/she stops scrolling the UIScrollView stops on one of the views that I have already created in the main UIScrollView.
In addition to this, I want to make an infinite UIScrollView with this style (check the image) & Change the 'gravity' (stop speed) when scrolling through a UIScrollView with paging enabled?
http://i.stack.imgur.com/JdLRL.jpg
I want to be able to scroll through it many items based on the flick speed. Thanks!

If it is really about scrolling only (the linked jpeg example may suggest it different) then you could do pretty much the same as Tutorials suggest about paging. Create a scroll view that hosts 3 views. One to the right and one to the left of the view that is currently visible. (You may want to go for 5 depending on the exact layout.)
Assuming the user scrolls from right to left. And your individual views are A, B and C. B is visible at the beginning. The user scrolls in a way that be moves out of view and c becomes visible. When c is fully visible latest then you could re-arrange the scroll view. Get rid of a, create view d and setup the scroll area in a way that B, C and D are the new subviews and C is visible. And so on and so on ...

Related

Select CollectionViewCell when scrolled into view

I have a collection view that is 100 points wide with a number of cells that are each also 100 points wide. I've got it setup to support scrolling and paging horizontally so the user can flick left and right and each cell occupies the entire collection view frame.
Originally, I had no scrolling and the user would tap each cell to activate something in the app. Now that its a narrow frame where only one cell can be seen at a time I feel that tapping is redundant and the cell should simply be tapped in effect when it comes in view.
Is there a way to trigger an event such as didSelectItemAtIndexPath when a given UICollectionViewCell becomes the one displayed within my collection view's frame?
UICollectionView responds to selectItemAtIndexPath:animated:scrollPosition:.
It also responds to indexPathsForVisibleItems which will be useful to determine where to make the selection.
You also need to decide when to make the selection, probably best after receiving scrollViewDidEndDecelerating: which the delegate inherits from UIScrollViewDelegate).
But it may be even better advice to look at what your code does upon selection and just do that (launched from the same place in code, probably when scrolling is finished), leaving selection out of it.

Remove 'hidden' images from UIScrollView

I have a scrollView that shows images set by url. Now I only want the visible image and the previous and next image to be pre-loaded onto the scrollView to reduce memory usage. How do I accomplish this?
If you use a UITableView instead of a UIScrollView, you can create your own UITableViewCell type which loads 1 image in its content.
The advantage is that only the visible UITableViewCells (those currently displaying on the device's screen) are loaded into the system memory, so it won't use too much resources.
Here is one of the many CustomCell Tutorials you will find on the Internet.
When I did the same I created a UIScrollView of 3 times the size. Just big enough to hold the 3 images, the one that is currently displayed and the next siblings to the right and the left.
Those images are pre-loaded if they have not been loaded before. So the user has some smooth and responsive look & feel.
When the user scrolls to the next one, and he can scroll for one only, then I re-arrange the view. Lets say images 1, 2 and 3 are in the scroll view and 2 is visible, so 1, 2 and 3 are (pre-)loaded. The user scrolls to the right. Image 3 will be visible. As soon as it becomes fully visible I set the visible rect of the scroll view to the middle again. Now Image 2 is the left most one, image 3 is visible and image 4 is placed as the right most one and pre-loaded.
When the end of the list of images is reached, meaning when the 1st or last one are displayed, then I place a dummy view on the left most or right most place respectivly that is a simple text view showing "no more images".
Unfortunately I cannot share that code.

How does the Reeder Mac app animate lists when switching folders?

Initially I was under the impression that it uses the table row slideup/down animations while inserting/deleting new rows but I doubt if it's doing that as it does it so fluidly even with thousands of items in the list (otherwise it would take a lot of time for the deletions/insertions to work).
Am I right in my assumption that it's simply attaching a new instance of the News list at the bottom of the screen, shrinking the above one while the one at the bottom expands to fill up space?
UPDATE:
Please see this video of what I mean: http://dl.dropbox.com/u/4960327/ReederAnim.mov
I can not tell you exactly how Silvio Rizzi made this, but as you see in the playback, a list view is added behind the shown list view, and the front list view fades out (.alpha = 0.0;) while the list view behind it expands its height per row.
When you desicate it frame by frame it becomes quite clear what he does, and it is really not that advanced. But I have to admit, with the white "milky" polished interface, it looks quite neat.
In addition, you can see that while animating, the background list view only renders the top 7 entries (hopefully calculated by dividing the view height with the average height of the cells shown) making the list view quick to load. Then afterwards, he can load an extended array of cells once you start scrolling, or in a background thread starting once the animation is complete.

Scrolling through UIButtons on a UIView

I have 50 UIButtons.
Only 10 UIButtons are allowed to show on the UIView at a time.
How do I set this up to allow the user to scroll through the list of 50 buttons?
thx
As the other users have said you can do it with a scroll view.
Personally I think it might be easier with a tableview, (provided its not a specific 10, just 10 consecutive buttons). You could arrange the tableview to remove the separators, and adjust the cell heights so only 10 cells fit on the screen.
This seems simpler to me. And you may have no need for UIButtons if you implement didSelectRowAtIndexPath:.
add the 50 buttons to a scroll view.
Set the scroll view to be paging enabled..
be the delegate and check the content offset of the scroll view to determine which page user is on..
load the buttons of the page..and remove other page buttons to free up memory.(add later when user come back to page)

Easy way to use an UIScrollView

Does someone have an "easy way" to make a view like camera roll app? I need to display miniature photos (buttons) and push new views from them. I don't know how to display miniature images in a scroll view. The number of miniatures is large, so they don't fit the screen, and I think UIScrollView is the only solution.
Check out TTThumbsViewController, part of Three20; this should pretty much do what you want (and it's open source if you need to change it).
A scroll view really just controls the visible region of a single content view. If you want a grid of small images, you'll need to create a view that contains a number of image views or otherwise displays the grid of images. Make this the content view of the scroll view. Also, it'd be a good idea to construct your image grid view such that it only loads and draws the images that are visible, particularly if you're going to display a large number of such images.