Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning iOS 5 Application Development
|
BOOK: Beginning iOS 5 Application Development
This is the forum to discuss the Wrox book Beginning iOS 5 Application Development by Wei-Meng Lee; ISBN: 978-1-1181-4425-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS 5 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 February 11th, 2012, 11:31 AM
Authorized User
 
Join Date: May 2010
Posts: 21
Thanks: 0
Thanked 6 Times in 4 Posts
Default Errata for Chapter 7, project ScreenRotations

In Chapter 7, in the project ScreenRotations, the positionViews: method should have an additional parameter and the first line commented out:
Code:
-(void) positionViews:(UIInterfaceOrientation) destOrientation {    
    // UIInterfaceOrientation destOrientation = self.interfaceOrientation; 
    if (destOrientation == UIInterfaceOrientationPortrait ||
        destOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        //—-if rotating to portrait mode—-
        btn.frame = CGRectMake(20, 20, 233, 37);
    } else {        
        //—-if rotating to landscape mode—-
        btn.frame = CGRectMake(227, 243, 233, 37);
    }       
}
So, when calling the positionViews: method, you should call it with the destination orientation:

Code:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
                               duration:(NSTimeInterval)duration {
    [self positionViews:toInterfaceOrientation];
}
Finally, in the viewDidLoad method, call the positionViews: method with the current destination:

Code:
- (void)viewDidLoad
{
    [self positionViews:[[UIApplication sharedApplication] statusBarOrientation]];
    [super viewDidLoad];
}
The original code in the book works when using the positionView method with the willAnimateSecondHalfOfRotationFromInterfaceOrient ation: method. However, since the latter method is deprecated, you need to manually pass in the destination orientation to the positionViews method.
The Following 2 Users Say Thank You to weimenglee For This Useful Post:
Brabbeldas (February 17th, 2012)
 
Old May 14th, 2012, 08:51 PM
Authorized User
 
Join Date: Dec 2011
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
Default The original code in the book also works if you...

...use the willAnimateRotationToInterfaceOrientation: method (instead of, as pointed out here, the willAnimateSecondHalfOfRotationFromInterfaceOrient ation: method).





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 7 ScreenRotations Errata FrankNatoli BOOK: Beginning iOS 4 Application Development 0 June 20th, 2011 09:30 PM
Possible Errata in Chapter 13? PMooney90 BOOK: Beginning ASP.NET 4 : in C# and VB 1 January 11th, 2011 01:50 PM
Chapter 4 errata notig BOOK: Beginning Visual C# 2010 1 September 23rd, 2010 10:27 AM
Chapter 22: Introduction to Project Management... Project Program integration chrisa BOOK: Professional Application Lifecycle Management with Visual Studio 2010 1 September 15th, 2010 03:28 PM
Chapter 5 Errata rogerj BOOK: Professional ADO.NET 3.5 with LINQ and the Entity Framework ISBN: 978-0-470-22988-0 0 February 21st, 2009 04:53 PM





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