Wrox Programmer Forums
|
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 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 May 17th, 2011, 09:42 PM
Authorized User
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 3 Page Control and Image View

Did my very best to follow the instructions for "Page Control and Image View" on pages 54-62. I'm using Xcode 4.0 which is slightly later than the version the book uses. iPhone simulator shows the view with the five dots on the bottom, but no images display. Can step from dot to dot, left to right, right to left, but no images. Tweaked PageController method to NSLog nextPage and indeed PageController is entered and nextPage steps up and down and repeatedly swaps between imageView1 and imageView2. Book puts JPGs in project folder "Resources" but Xcode 4 has no such folder. Initially I put the JPGs in the project root, then moved them to "SupportingFiles", but no images displayed in any case. Downloaded the source for everything from Wrox, but nothing in Chapter 3 appears to correspond to "Page Control and Image View". Would be most grateful for debug suggestions.

New information: page 57, figure 3-16, shows a black background Page Control that occupies a relatively small sliver at the bottom of the display, and a blue-gray UIImageView above it occupying most of the display. That's not what I see in my project. I see all black, top to bottom. If I resize the Page Control, it's only 36 pixels high, and as wide as necessary for the five dots. Why is the entire display black?

Also, found the Wrox sample code for this project, and while it does successfully display the first Mac image, no Page Control is visible and there is no way to step through the five images.

Last edited by FrankNatoli; May 18th, 2011 at 09:47 PM..
 
Old May 20th, 2011, 12:44 AM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

if you are still having issues with your project, send it to
[email protected]
and I will take a look at it for you.

You might also check some of the threads in the Beginning iPad Application Development forum. The same project was in that book (also, not in Xcode 4 of course) and the discussions there might give insight to help solve your problem.

Bob
 
Old May 29th, 2011, 12:01 AM
Registered User
 
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I also had problems with this example, and so I checked the errata, sure enough it is listed there, and now it works.

Here is the link to the errata page:
http://www.wrox.com/WileyCDA/WroxTit...Cd-ERRATA.html

It's disappointing that such a simple example contains errors, and I'm now wary of the rest of the book with the more complicated code. How hard can it be to run these examples and make sure they work?
 
Old May 29th, 2011, 10:12 PM
Authorized User
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When you start as I am, an Apple neophyte, the slightest error is a show stopper. A lot of the problems are Xcode 4 [the current release] versus Xcode 3.6 [the book version]. That's Apple's fault, not the author. Just have to keep hammering, I guess.
 
Old May 30th, 2011, 12:21 AM
Registered User
 
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The version of your IDE should not make a difference to the code that you are compiling and running. The problems in the sample are bugs, and not due in any way to using xcode 4.
 
Old June 12th, 2011, 10:45 AM
Authorized User
 
Join Date: Jun 2011
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am also stuck at this section and am wondering if this has ever been resolved. Is this forum even monitored by WROX staff or the author? As far as I can see the entry on the errata page is by a customer/user, not an official entry by WROX.

I can basically get the version that is supplied as a download to work, but it still seems that tempImageView is assigned twice (once in the switch loop and then again in the if/then statements) so I am not sure how the assignment in the switch loop can have an effect.

I would be most thankful if this was cleared up from an official side.
 
Old June 12th, 2011, 12:17 PM
Authorized User
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I finally got the project working with Xcode 4. If you will list, step by step, exactly what you do for pages 54-62, I will repeat those exact steps and let you know where you went astray.

Would also be helpful for you to zip/compress the complete project directory and e-mail to me frankjnatoli-at-embarqmail.com. Advise if you are not familiar with Mac OS X zip/compress procedure.
 
Old June 12th, 2011, 01:03 PM
Authorized User
 
Join Date: Jun 2011
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Frank, I emailed the project to you. Here is the section of code I don't understand:
Code:
- (void) pageTurning: (UIPageControl *) pageController 
{	
    NSInteger nextPage = [pageController currentPage];   
        switch (nextPage) {                           
        case 0:
            [tempImageView setImage:
			 [UIImage imageNamed:@"iMac_old.jpeg"]];
            break;
        case 1:
	//...//	
            break;
        default:
            break;
    }
    if (tempImageView.tag == 0) {                                       
        tempImageView = imageView2;         
        
       /*  Here tempImageView is overwritten with imageView2, 
           but didn't we just assign an image to it in the switch loop? 
           How is @"iMac.jpeg" remembered?  */
        
        bgImageView = imageView1;
    }
    else {                                      
        tempImageView = imageView1;
        
        /*  Here tempImageView is overwritten with imageView1, 
         but didn't we just assign an image to it in the switch loop? 
         How is @"iMac.jpeg" remembered?  */
        
        bgImageView = imageView2;
    }	
    [tempImageView setHidden:YES];
    [bgImageView setHidden:NO];
}
 
Old June 12th, 2011, 04:44 PM
Authorized User
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

tempImageView is always the foreground view.

bgImageView is always the background view.

The switch statement assigns the "nextPage" image to tempImageView.

The if-then-else statement flips between imageView1 and imageView2 using tempImageView and bgImageView. It checks what is the current "tag" value. If zero, i.e., imageView1, it flips to imageView2 foreground and imageView1 background. If one, i.e., imageView2, it flips to imageView1 foreground and imageView2 background.

Is this your question? Or does your project not flip photos as documented?
 
Old June 12th, 2011, 06:10 PM
Authorized User
 
Join Date: Jun 2011
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply, Frank.

Since all animation has been removed by (why they even introduced that at the same time as introducing page control - I don't know) there is now no need for foreground and background images.

I am simply trying to nail down the point at which a new image is shown on screen.

I do understand that a new image - according to the current page - is loaded into tempImageView in the switch-loop. what I don't understand is how and when this image is loaded into one of the imageViewx files and unhidden. It seems in both cases of the if/then loop the tempImageView is once again overwritten by imageView1 or imageView2 respectively. Shouldn't it be the other way around, since those two are the ones that actually display on screen?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Image to Image Control using JavaScript ctranjith General .NET 1 May 28th, 2013 05:43 AM
Chapter 3 Page Control & Image Views programmer2010 BOOK: Beginning iPad Application Development 10 January 12th, 2011 09:06 AM
Ch3 Page Control Image View nauticalmac BOOK: Beginning iPad Application Development 0 August 24th, 2010 06:59 AM
View of image fields AlexSepahpour SQL Server 2005 0 October 24th, 2007 06:06 PM





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