Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-10-2010, 04:18 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 19
hehe0613 is on a distinguished road
Default Using multiple viewControllers, memory advise

Dear All
I'm creating an iPad application, based on a split view controller.
My detail (or right) view controller features a scroll view where I need to add multiple view controllers.
Each view controller (instantiated on the scroll view) requires a large amount of memory, it contains a picture, some buttons and so on.

My question is : How to handle memory management for such a situation ?

Basically I created an array of view controllers, so I keep a reference on each instantiated viewcontroller, and each time a button on any viewcontroller is pressed, I'm able to perform the corresponding action.

Unfortunatelly I have some memory issues due to the large number of instanciated viewcontrollers.

Releasing these view controllers once their view is added to the scrollview does not work since I loose the viewcontroller reference, thus pressing a button of the released viewcontroller result in a call to a deallocated viewcontroller.

So what would be the best practice for instantiating multiple view controllers in a scrollview ?

Is there a way to save (to file ?) a reference of the viewcontroller ? so I can free up memory and reallocated once required ?

Any help would be greatly appreciated !
Thanks
J
hehe0613 is offline   Reply With Quote
Old 12-10-2010, 04:40 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Amsterdam, The Netherlands
Posts: 782
TUX2K is on a distinguished road
Default

Well I've run into a similar problem, only I had to add many images to one scrollview.

The tick I use, is to only load to viewcontroller that is currently visible, and the 2 just next to it.
When the users scrolls i load the next view controller and add it, removing the viewcontroller that is no longer next to the visible viewcontroller.

This lazy loading princable work really well.
TUX2K is offline   Reply With Quote
Old 12-10-2010, 10:12 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 19
hehe0613 is on a distinguished road
Default

Thanks for the tip !
I was also wondering if it is possible to

- remove the scrollview and
- use a tableview with customs cells, each cell would be one viewcontroller.

?


Quote:
Originally Posted by TUX2K View Post
Well I've run into a similar problem, only I had to add many images to one scrollview.

The tick I use, is to only load to viewcontroller that is currently visible, and the 2 just next to it.
When the users scrolls i load the next view controller and add it, removing the viewcontroller that is no longer next to the visible viewcontroller.

This lazy loading princable work really well.
hehe0613 is offline   Reply With Quote
Reply

Bookmarks

Tags
array, issue, memory, multiple, viewcontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 383
7 members and 376 guests
chemistry, daudrizek, HemiMG, jeroenkeij, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,665
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daudrizek
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:56 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0