Remove 'hidden' images from UIScrollView - objective-c

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.

Related

How to build below screen in titanium?

below i attached an app help guide screen. I am understanding how to build this screen.
If any body have idea please share here
View with semi transparent background color (backgroundColor:"rgba(0,0,0,0.5)";) and some images on top of it.
So, using images is bad. You'll need images for translations and if you do this as one image you'll need to ensure all devices are covered so your arrows point to the right element.
Minimise images == smaller app.
First thing you'll need to do is a create a blocker view -- so that's a view that will fill the screen and have a black background with opacity.
You can't apply that to the window as everything in it will be semi-transparent so:
Create a transparent Window that fills the screen.
Add to that window a view that fills the window and has opacity say 0.5 and black background
Add to the Window (not the view you just created) the other elements and button -- ideally, these should be individual graphics of the arrows, sized in such a way that you can position them based on the host element (the item they are pointing to / referring to). Use real text so you can handle translations / reduce file size.
So you'll need a way to associate each tip with a control they are anchored too, and that will ensure that regardless of the screen size, the tip will appear in the correct place.
First of all, always give a try before putting questions anywhere because it makes you learn things on your own for long time.
The easiest step for you to do this is to ask your designer to create a complete image just like that & you just have to show it on top.
If you have to show that image in different translations, then you can ask your designer to provide you required translations images.

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.

Several UIScrollView Questions

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 ...

I can't understand UIScrollView behavior

I've read a lot of documentation but still don't really understand how that UIScrollView works.
I have an example where I use an UINavigationViewController with the status bar (little top bar with wifi, battery, etc., icons) and a navigation bar (with the "back" button).
As the first subview of the UINavigatioViewController's main view I have a UIScrollView. Inside it I have created several subviews that make it's contents size to be 500 points.
In the "viewDidLoad" method I set the scroll view's "contentSize" equals to 500. But it doens't completely scroll down to show the last subview.
I read that I should add some points to the "contentInset" because of the "bars". I don't really know why. Isn't the scroll view inside the main view that is correctly framed? Why does it need to take the "bars" into account?
Anyway, I read that it should be like 64 points (44 navigation bar + 20 status bar). But it doesn't work.
The "magic" number (at least for me) is 84 points. I must add that quantity to the content size (584) or use it as:
self.scrollView.contentInset=UIEdgeInsetsMake(0.0,0.0,84.0,0.0); // AT THE BOTTOM!!
I'm really confused about this. Could anyone give a hand on understanding it?
Thanks.
self.scrollView.contentInset=UIEdgeInsetsMake(0.0,0.0,84.0,0.0);
UPDATE
I have seen that because I made my ScrollView size bigger in Interface Builder in order to add new elements beyond the normal small visible size, it had a "frame" size near to 500 points.
I set it frame size to 416 (just to fit and cover all the visible space) and now with a content size of 500 points (without any additional inset values) it scrolls perfectly.
But I still don't understand the previous behavior...

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.