Image Caching Problem in iPhone - iphone

I have briefly described the working of my application to under stand my Question.
I have an application, in which more than 1600 images are stored with in iPhone-Application-Document Directory.
I have a tableView on Main Screen as follows.
=>First Category
=>Second Category
=>Third Category
=>if user selects First category, Images are loaded in my ScrollView
Like
|--------------------Page View Controller-----------------|
| First Image | Second Image | Third Image | Fourth Image |
|--------------------Page View Controller-----------------|
After selecting Category, User can see - First Image From Page view Controller & others are already loaded in page View Control, user has to just scroll left - right to see the other images, but at a time user can see only one image.(that is the task of page view control)
Now Each Page has an Image View Placed in Scroll View (so user can zoom in out)
All this things work Perfectly,
Problem occurs in following situation.
=>After watching first category's images
=>User presses Back
=>Now user selects second category to view all images of second category are loaded in page view controll.
iPhone terminates the application in the given situation. (as it can't load all images to page view control)
(each image is of at-least 4 MB approximately.)
iPhone simulator works perfectly in described situation but iPhone doesn't.
iPhone terminates the application in given situation.
I think there might be memory caching problem in iPhone.
Question is how to resolve this problem?
Thanks in advance for helping me.

You are having a memory problem, you need to manage your pictures better, release them from memory when not in use. For your scroll view dont load all images at once, load at most three, this is all you need, the reason i say three is because youll have something like this
PIC ActivePic Pic
or
ActivePic Pic - here you only need 2
You load picture on each side of the active picture so when the user scrolls clipping does not occur. When you are not in the scroll view make sure to release all the images if not ull run out of memory like you have been expiriencing. Look at the sample project PageControl here http://developer.apple.com/iphone/library/samplecode/PageControl/, here they manage t he views of the scroll view in the same fashion described above.

Related

iCarousel same images issue

In my carousel view after 7 images next image shows the first image , the other one shows the second image although they are different images. I mean after 7 images they start repeat images. I am sure it is coming different images. My images are buttons. When i click them they show detail view. In detail view they show correct images but in carousel not. Do you have any idea what causes that. Thank you.
It sounds like you are using the reusingView feature wrongly.
You can fix it by increasing numberOfVisibleItems, but that's not actually the right way to do it since it uses up more memory and slows down the carousel.
Paste your carousel:viewForItemAtIndex:reusingView: method into the question and I'll check it for you.

Using One UIImageView that Changes Based on Button Pushed

This is a very basic question, but I cannot figure this out. I'm new to iOS/XCode. I've gone through a few tutorials that somewhat covered this (but a little more complex). I have an Android app that I'm trying to port over to iOS. I'm using storyboards for this app.
The basic premise is that the app contains 27 thumbnail/full images. For this question, we'll say the 27 pictures are split into 4 categories: cats, dogs, sharks, whales. Currently, I have the app launching with Navigation Controller w/ View that shows 4 Buttons with these categories. These push out to 4 separate view controllers each set up with buttons with the thumbnail as the image. I want to select the thumbnail and show a scene with the full image. I only want one full image view controller with a UIImageView in it that will display the full image of the thumbnail pressed. (Using table views may be easier, but I want to control the user interface and have more than just a rows of items to select.) Also, I'm not sure if this matters in the eventual set up, but from the full image scene I will want to add a play button that will play a local mp4 file (but that's for another day).
The image set will remain static so I was trying to incorporate NSArray with the full image name stored. I believe I have to add a file that is subclass of ViewController and incorporate code that will take on the full image file name based on the button pushed. This is where I'm stuck. In java for Android, I just had listeners on each button and used a case statement to set the full image variable and passed it to my full image class/xml.
Another option I think I remember seeing somewhere is I could use the title of each button and enter the full image name there. Then when the button is pressed, the title is passed to the full image view. I think this eliminates the need for an array (???).
Any help is appreciated.
Thanks,
Jason

photo library like swipe taking time delay

I've made a image gallery with a swipe effect to skip through the uiimageviews.i am using a scrollview to do this.adding all my images in to scrollview using a for loop and am inabling the pagesEnabled=true
myScrollView.pagingEnabled = YES;
but it is taking more time in the case of multiple images.
i have a gallery page and preview page .when ever user clicking the thumb image in gallery page it will navigates to preview page .am doing the looping in preview page's view did load.but it is stucking in gallery page itself and after creating all the images inside scrollview it is showing the preview page.
my question is is there any way to avoid the time delay.??
or there is any way to load all the images after getting inside the preview page(then i can show some loading symbol there insted of stuking and showing the galllery).
There are too many images in the best thing is only to load 3 Images and then to replace the images when you are scrolling to the next. You can check out the Apple WWDC Session 104 for more information about this.
If I understand you correctly, you need to restrict your drawing to only those images currently on the screen. It takes time and memory to draw the images you can't see, and so, the more you add, the slower everything gets, for no benefit. There have been a number of good WWDC presentations on this in the last couple of years. Go to iTunes U (in iTunes) and sign up for the WWDC 2010 and WWDC 2011 videos. Look for ones on implementing scrolling and scrolling performance.

How to display a grid of more than 1000 thumbnails as ui views in UI Scrollview with smooth scrolling

I have to implement a application which displays a grid view of thubmnails each of which is a clickable object. The grid view will display 2 images( which i suppose can be a uiview). And 4 rows per page.
The use should be able to smoothly scroll through the image grid view. The images for the thumbnails will be fetched from the url i get from server. However assuming i have the urls in my model how can i implement this feature to display them.
Few problems i have encountered are:
All the images(UIviews) cant be loaded due to memory constraints. Hence paging can be enabled.
On implemented paging using uiscrollview delegate the ui becomes irresponsive for some time. I am downloading the images in a NSOperation queue and posting the image on mainthread for displaying on screen.
I want the scrolling to be very smooth without jerky feature.
How can i implement this?
TIA,
Praveen S
I was having a similar problem.
What i did was at an instance i kept only 3 pages(or screens with 4 rows as you said) in the memory and cleared remaining all.
If suppose there are 3 screens s1, s2, s3. And the user is viewing s2. Whenever he scrolls to s3 i will remove s1 and load a new page s4. So that at any point of time there will be 3 screens only.
And the users will have a better experience. And also less memory will be occupied.

Good ways to dynamically generate the start image of an iPhone/iPad app

I'm self-learning iPhone development and I see that one of the aspects of an iPhone/iPad app is the start image that gets displayed when your app is run. I'd like my start image to display some basic info about the user when the app is launched, but that info has to first be collected by the user when the app is first run. That tells me that I either need to dynamically generate the start image after the user enters their information or I need to place a label of some sort on top of my static start image in order to accomplish this. The first time the app launched and before the user enters their info, the start image can be anything or nothing at all, I'm not concerned about this.
So, my questions are...
Can you place controls, like a label, on top of the start image when your app is launched?
If not, what's a good approach to dynamically generating the start image after the app is launched for the first time and the user info is collected?
If there's no way to change this start image (thanks kristopher!), can I instead display my dynamically generated image for a set amount of time (~3 seconds) as soon as the start image closes? Do I even have to use a start image at all?
Thanks so much in advance for your help! I'm going to begin researching this question right now.
To answer number 3, Yes, you need a start image. It should look like your dynamic start image but without the dynamic information.
To display the dynamic information briefly after launch, just use a modal view controller on top of whatever view controller comes up first (called viewController below):
SplashScreenController *splashScreen = [[SplashScreenController alloc] initWithNibName:#"SplashScreenController" bundle:nil];
[viewController presentModalViewController splashScreenController animated:NO];
[splashScreenController release];
[viewController performSelector:#selector(dismissModalViewControllerAnimated:) withObject:YES afterDelay:3];
Obviously you need to create a UIViewController subclass and xib file called SplashScreenController.
Apps can't change their start images. Those image files, as well as other files in the app's bundle, are treated as read-only by the OS.
If you don't have a startup image, then the user will just see a black screen for a second or two (or more, depending on how big your app is). It's a good idea to have a startup image.
You can display whatever you want after your app starts running.
I do something similar to what you are trying to accomplish, except I do not display user information. If you want to see what I did, check out my app How Long Can You Tap It (free). The Very first image, as Kristopher mentioned, is not changeable. It will be displayed for as long as the application takes to load. Then, the image will disappear and show your initial viewController, which will be whatever you want. In my app, it simply is the same image is the initial image, but instead of saying LOADING I display text telling you to Tap the screen to start playing. If you don't want to rely on the user to tap the screen to continue, you can do what Frank said and dismiss it within X number of seconds. If you want more code than what Frank provided, let us know.