Wrox Programmer Forums
|
BOOK: Beginning iPad Application Development
This is the forum to discuss the Wrox book Beginning iPad Application Development by Wei-Meng Lee; ISBN: 9780470641651
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iPad Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 10th, 2010, 03:21 PM
Registered User
 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 4 - Switching Views

Hello,

Great book BTW.

I have a question about the switching views section. I noticed that if you run the app then click the button and switch to the second view then close the app. When you relaunch the app the second view is the view that appears. Is there any way to force it to always show the first view no matter what last view was shown?

thx,
todd
 
Old December 10th, 2010, 10:30 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

If you are asking about the project continuing on p 103, you might want to revisit your code. That is different behavior than the result I get, and the result from the project download source code. The first view with the button comes up each time the app is launched, for me, and the download.
If you can't find a discrepancy, include your code in a reply, and it should be able to be diagnosed.
 
Old December 14th, 2010, 12:49 PM
Registered User
 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, thanks for the reply.

Yes, the code starting on page 103. The source code download includes everything through the top of page 108. I am running the downloaded source code 'windowBasedApp' of which I have made no modifications and when I run the app in in the simulator (my base iOS SDK is 4.2) if I switch to the second view, quit the app then reopen the app the second view appears.
 
Old December 15th, 2010, 02:52 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

I had done all the projects on 3.2. Things respond differently in 4.2 when quitting.
Quitting an application responds differently now that background tasks are supported. The application doesn't actually quit, until something else needs the resources (memory). The last state of the application persists. If you want the initial screen to come up you can insert the following into the …AppDelegate method
Code:
- (void)applicationWillResignActive:(UIApplication *)application {	
	NSArray *subViews = [[[window subviews] objectAtIndex:0] subviews];
	if ([subViews count] == 3) {
		[[subViews objectAtIndex:2] removeFromSuperview];
	}
}
the method
- (void)applicationWillTerminate:(UIApplication *)application
and
-(void)dealloc
appear to only be called when the system quits the program.

Further info is available here or in your documentation
http://developer.apple.com/library/i...Reference.html

This works for the program as written in the book. In something more complex you would tag your views.
Keep in mind this behavior is not necessarily what you will want. For example, if your program is interrupted by another task, e.g. new mail and you switch to the Mail program, you most likely would want to return to the screen in the state you left it, not the program start screen.
Hope this helps. Let me know if there are any questions.
Bob
 
Old December 17th, 2010, 04:01 PM
Registered User
 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Bob! that really helps a lot. It makes perfect sense now. And thank you for taking the time to answer.
 
Old December 20th, 2010, 11:01 AM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

Happy to help. It is a good way to test how well I understand the material.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 4 ToDo List - modifying existing views floickelsheimer BOOK: Professional Android 2 Application Development 2 April 29th, 2010 11:34 AM
Chapter 4 - Two Views, not working for me... bigtalk BOOK: Beginning Ruby on Rails 1 January 3rd, 2008 07:30 AM
Chapter 7 - List Views Not Refreshing VBNovice BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 3 January 31st, 2007 08:26 PM
converting Access 2000 views to Sql views matta Classic ASP Professional 1 January 26th, 2005 03:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.