Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning iOS 4 Application Development
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning iOS 4 Application Development
This is the forum to discuss the Wrox book Beginning iOS 4 Application Development by Wei-Meng Lee; ISBN: 978-0-470-91802-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 4th, 2011, 03:12 PM
Registered User
Join Date: May 2011
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Ch. 20 - Compass & Rotations not working

Hi All,

Did anyone get the Ch. 20 lessons on detecting a device's ROTATION (page 493-498) and displaying it via a rotating Compass image to work?

I'm not getting any run-time errors, exceptions or warnings - everything runs fine - but they just plain don't work for me. The compass image shows up but doesn't rotate, and the label-field that's supposed to be displaying the Degrees of rotation doesn't update its values either.

The problem continues with the next lesson ("Rotating the Map", pg. 498-504) - the code executes fine, but no results.

I downloaded the author's source-codes and ran his versions as well for both of these - they don't work either. Again, no errors are generated - but the apps just plain don't do what they're supposed to do.
(And yes, I built both apps onto my device - a 2nd. generation iPod Touch - and ran them from there, as per the instructions.)

If anyone has figured out what's wrong - please share with the rest of us!

Thanks :-)
Reply With Quote
  #2 (permalink)  
Old June 6th, 2011, 10:25 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts

Does the author say that the code will work on an iPod Touch? It works on iPad and iPhone, but I can't see how it can work on iPod touch. (It doesn't on my 4th generation.) There is no compass in the iPod touch.
The 3 minor issues I had with the project. (identical in the previous book). In that version it was set up on iPad and presented in landscape mode. The in CLLocationManager the default headingOrientation assumes UIInterfaceOrientationPortrait, so it is necessary to set the CLLocationManager heading orientation to whichever landscape mode you use or the compass will not indicate north in the correct direction.
Second in the MyAnnotation class the <MKAnnotation> protocol provides accessors
-(NSString *)subtitle;
-(NSString *)title;

The instance variables that he provides for the class are
NSString *title;
NSString *subTitle;

The accessor generated by the @synthesize for title is overridden by his written accessor, which is identical to the one that the @synthesize would generate. A simple approach, which I did, is to name the instance variables
NSString *title; (as in the book)
NSString *subtitle; (small 't' on title)

This way the accessors provided with @synthesize take care of everything.

There is also a memory leak, the
[mapView addAnnotation:annotation];
should be followed by
[annotation release];
since the mapView retains the annotation.

Reply With Quote
  #3 (permalink)  
Old June 6th, 2011, 11:15 PM
Registered User
Join Date: May 2011
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

1) sorry, but I had no idea there was no compass on the iPod Touch. (Is that supposed to be common knowledge?)
That explains why the App runs error-free but doesn't actually do what its supposed to.

2) The author does not indicate specifically that it won't work on iPod Touch.

3) I was wrong about my own device - I actually have a 4th Gen. iPod Touch, not a 2nd. Gen. (but I guess that doesn't really matter if none of 'em support compass anyway...)

4) thanks for pointing out the other problems with this particular lesson - especially the memory leak one and the landscape/portrait mode issues - good to know.

I'll be getting an iPhone soon, so I look forward to testing/fixing this app on it...

thanks as usual Bob
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adapting Ch. 20 code, to create a 'SELECT' DataSet ? liamfitz BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 1 July 7th, 2009 10:56 AM
SQL Express & Ch 20 Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 1 August 2nd, 2007 05:16 PM
TCPSend/ Receive system.dll problem (ch 20) dingke BOOK: Professional C#, 2nd and 3rd Editions 0 March 10th, 2004 05:42 PM

All times are GMT -4. The time now is 11:03 PM.

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