UIScrollView paging works fine in simulator but application crashes in device after 15-20 pages - iphone

I have used UIScrollView with paging enabled. I have more then 1000 images and I am adding 12 images per page. I am loading 12 images every time when page is scrolled. But after scrolling 15-20 page application is getting crashed in device. It works fine with simulator. Please let me know what can be the issue ?
Thanks in advance.

You didn't provide any code but it looks like this is a case of bad
memory management, as all the comments suggest.
One way to solve this would be to allocate just three pages (each holding 12 images)
and then joggle with their positions and contents according to user interaction.
I think you'll find these two links helpful:
Creating Circular and Infinite UIScrollViews
UIScrollView Infinite Scrolling

Related

Scrolling in "RepeatBox" control is not smooth

I have two pages, first page I have a ScrollView control and the other page I used RepeatBox control.
My problem is the ScrollView page scroll is smooth, But the RepeatBox page scrolling is not smooth (i.e. flickering while scrolling).
Could any one help on this? Thanks in advance.
Performance of repeatbox can change according to the objects you used in it. Because it is drawn with rowRender event, it can take more time with different objects. Also, in some old devices, especially for Android, you can see these kind of performance differences in applications.
Maybe you can test with other devices, or you can test with more simple project in order to see if it is always flickering or not.
The problem comes with all images on the visible screen are opening again from the local storage by rowRender method. In the native RepeatBox after image comes on visible area are stored and not again opening from local storage and creates performance problem.

May many webviews cause my app to crash on my iphone 4?

//The point
I gradually load many objects (UIWebView) to the memory and after a while it crashes. Please Help
//Details
I have a UIScrollView with horizontal paging, wherein each page (with a separate view controller) contains a UIWebView with disabled user interaction. At first only webview #0 on page 0 gets loaded and as I advance through the pages the app gradually sends requests to load specific data. Downloaded data stay in memory.
After I load about 20 Webviews from internet source, my app freezes and crashes. If I use a dummy html string stored on the device, this happens after I load about 50 webview. But the problem persists.
I fixed much of the leaks and am only left with Mallocs. Since the problem does not occur with low quantities of UIWebviews Loaded I assume that I have to change my code to say 3 webviews and reuse them. But I don't know if that'd fix the issue. I have developed several apps before which don't crash and this is a unique case.
I store pointers to webviews and some other elements inside every Webview (such as labels) in arrays. The arrays get incremented in count with every new page loaded.
I use xcode 4.3 and a jailbroken iphone 4 to develop. I turned off requiring signatures in my xcode as a result of which the app gets copied onto my phone yet fails to attach to process. I cannot debug on my phone. My app works well in simulator but crashes a while after I launch it on the phone by tapping the icon.
From what I am able to describe as so, what do you think might be the problem?
Thanks
Yes, certainly having too many UIWebViews will cause a crash due to low memory. I'm not sure what your reason is for having multiple UIWebViews, but I would follow through with your idea to reuse a smaller amount of them instead of creating several.
Based on your device not crashing when you use a small amount, I would say that the problem lies in the use of too many UIWebViews and not in a compatibility problem with your jailbroken device, for example.
WebKit is notorious for its memory hogging. It mallocs large blocks of memory and fails before giving you the opportunity to release other resources. One UIWebView is bad enough. I've had this problem in apps with as few a 5 UIWebViews, let alone 50.
There are a couple of things you can try. One, if the web pages aren't too complicated, you could use a replacement view such as DTCoreText to render them. If you have to have webviews, you could cache the various HTML contents and re-render using one UIWebView.
You only need to use three UIWebView's for paging. Lets say the user is on page 2 (page 1 is the left page and page 3 is to the right). When the uses swipes to page 3, you could just display the web view currently on page 1 on page 3. You need to re-load the proper html when the user swipes between the pages.
With some caching of the web content, speed shouldn't be a problem once the stuff is downloaded.

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.

App like default photo browser in iphone?

i am developing a app which contains feature like default photo browser in iphone. I done some what similar to that. but after loading some(near about 10-15) images from remote server,i am receiving memory warning.My requirement is loading image one by one. For this, on scroll view i am putting an images and increasing the contentSize of scroll view. it will work fine. but due to memory warning app quite.
Guys, any have any idea to approach for this feature which work similar to photo app without problem?
thanks in advance .
You're running out of memory because you're keeping the data for 10 or more images in memory at one time. You need to have more logic in your code that not only preloads and increases the scroll view's content size, but also removes UIImageViews from the scrollview (and thus from memory) as the user scrolls to newer stuff. (You can also save "evicted" images to the cache area on disk so if the users scrolls back you don't have to go to the server again.)
If you use a UITableView, it will request the images only when needed, and will automatically purge off-screen cells to save memory. It may not fit into the aesthetic for your application, though.

Is there any problem for loading images more than 200 from resource folder?

My application contains more than 200 images each with size approx. 15 KB. I want to flip these image one by one. Is there will be any time lag for loading images? Is there any alternate method for doing that?
Anyone please help!
My application contains more than 200 images each with size approx. 15 KB. I want to flip these image one by one.
OK.
Is there will be any time lag for loading images?
Maybe. Try it and see. If there is, run your app under Instruments to see what really caused it.
Is there any alternate method for doing that?
You haven't proposed a primary method to be alternate to.
The main thing is that, since this is an iPhone app, you're probably not going to need 200 images loaded at once. Consider the Home screen: Those icons are about as small as is practical, and there are only 20 (24 on the iPad) of them on the screen at one time.
Assuming you want to allow scrolling or paging through the list, you'll probably want to keep a pageful up and a pageful down already loaded and flipped and ready to display, to make scrolling/paging faster. That's still only 60–72 images, and you can do half to two-thirds of them after displaying the visible 20–36.
Moreover, are the images always flipped? If so, then flip them at build time and copy the flipped images into your app, and do no flips at runtime. Then you're just displaying images.