开发者

Which template should i choose for iphone app having multiple pages to view without more memory consumption

I want to develop an app having multiple pages. For example the first page has all menus in it. If you click on one menu it will go to some list page. If you click on some items in the list again it goes to another page with full details of that item and it goes on. In every page there is another menus relevant to that page. If i click on that menu it will take me to that particular page and come back to same page from where i clicked the menu.

I searched through the web and i came across that Navigation-Based template is best to implement this.

I had little concern in memory management point if i navigate from one page to another continuously for more than 3 or 4 pages Navigation-Based approach will开发者_如何学JAVA keep all the views in the stack which eats lots of memory. Is this a best approach or is there any workaround to implement this kind page navigation.

Whether the Navigation-Based approach will take care of memory problems when i navigate from one page to another. If my understanding is wrong correct me.


Seems that you take the memory management part too high.
Why shouldn't you use a predefined function which is used in million other apps?

Or another question which really (and I mean really) big interface which will consume 40 mb of memory? The iPhone is really efficient with it's own UI. Your first part in memory management is to take care of your allocations so that no leaks appear.

The views stay in memory and should stay in memory because no one want to wait a few seconds while navigating from one view to another. (But of course you can remove unnecessary UI elements while of screen)


Do use UINavigationController, it's the best one for your needs.

And also read something about viewDidLoad / viewDidUnload methods of UIViewController class. These are called when your view is not "visible" (= unloaded) and loaded again. They help you to use memory efficiently. You should also look at memory warnings (didReceiveMemoryWarning method).

It's quite simple - in viewDidUnload, release everything what can be reconstructed in viewDidLoad method later. It helps you to keep memory footprint as small as possible.


I am new iphone programming. Still if you think this useful then use it.

You can use tab bar for your MAIN MENU. When user click on particular tab , user gets list of menus relevant to that page. After this when user selects any menu then new view is pushed. So it will minimize number of views pushed by 2. In this way you can come back to same menu using back button.

If you take proper precautions while allocating & deallocating memory used then there will be no issues of memory consumptions.


The utility template is a good start, you can add more 'flipVeiws' or load the original 'flipView' with different content depending on which button is pressed on your 'homepage'. This content could come from a plist array etc.


You can use following code to find out how much memory is taken by ur app
struct task_basic_info info;
mach_msg_type_number_t size = sizeof(info);
kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
if( kerr == KERN_SUCCESS ) {
NSLog(@"Memory in use Root(in bytes): %u", info.resident_size);
}
else { //NSLog(@"Error with task_info(): %s", mach_error_string(kerr)); }
Also Use didReceiveMemoryWarning method to find out wheather your app is crossing memory limit

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜