Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 5th, 2012, 11:37 AM
Registered User
Points: 23, Level: 1
Points: 23, Level: 1 Points: 23, Level: 1 Points: 23, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Exclamation Using Views Page52

Hi I am also a new bee and Im reading this book so far my code works fine but only two images are displaying the first image then continuously second image I tried an NSLog statement of the tempImageView.tag its 0 it doesn't change to any other value please help my code :

Code:
- (void)viewDidLoad
{
    //init the first image view
    [imageView1 setImage:[UIImage imageNamed:@"img1.jpeg"]];
    tempImageView = imageView2;
    
    //make the first image view visible and hide the second
    [imageView1 setHidden:NO];
    [imageView2 setHidden:YES];
    
    //add event handler for the page control
    [pageControl addTarget:self 
                    action:@selector(pageTurning:) 
          forControlEvents:UIControlEventValueChanged];
    
    prevPage = 0;
    [super viewDidLoad];
}

//when the page controller's value is changed
-(void) pageTurning: (UIPageControl *)pageController{
    //get the page number you can turnning to 
    
    NSInteger nextPage = [pageController currentPage];
    
    switch (nextPage){
        case 0:
            [tempImageView setImage:
             [UIImage imageNamed:@"img1.jpeg"]];
            break;
        case 1:
            [tempImageView setImage:
             [UIImage imageNamed:@"img2.jpeg"]];
            break;
        case 2:
            [tempImageView setImage:
             [UIImage imageNamed:@"img3.jpeg"]];
            break;
        case 3:
            [tempImageView setImage:
             [UIImage imageNamed:@"img4.jpeg"]];
            break;
        case 4:
            [tempImageView setImage:
             [UIImage imageNamed:@"img5.jpeg"]];
            break;
        default:
            break;
    }
    
        
    //switch the two imageviews
    if(tempImageView.tag == 0){
        tempImageView = imageView1;
        bgImageView = imageView2 ;
    }
    else{
        tempImageView = imageView2;
        bgImageView = imageView1 ;
    }
    
    
    UIViewAnimationOptions transitionOption;
    if(nextPage > prevPage)
        //--if moving from left to right
        transitionOption = UIViewAnimationOptionTransitionFlipFromLeft;
    else {
        //--if moving from right to left
        transitionOption = UIViewAnimationOptionTransitionFlipFromRight;
    }
    
    //---animate by flipping the imagees---
    [UIView transitionWithView:tempImageView 
                      duration:2.5 
                       options:(transitionOption) 
                    animations:^{
                        [tempImageView setHidden:YES];
                    }
                    completion:NULL];
    [UIView transitionWithView:bgImageView 
                      duration:2.5 
                       options:(transitionOption) 
                    animations:^{
                        [bgImageView setHidden:NO];
                    }
                    completion:NULL];
}
Reply With Quote
  #2 (permalink)  
Old June 5th, 2012, 01:07 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
Default

Your if…else is incorrect

Code:
    //switch the two imageviews
    if(tempImageView.tag == 0){
        tempImageView = imageView1;
        bgImageView = imageView2 ;
    }
    else{
        tempImageView = imageView2;
        bgImageView = imageView1 ;
    }
should be

Code:
    if (tempImageView.tag == 0) { 
        tempImageView = imageView2;
        bgImageView = imageView1;
    }
    else {                       
        tempImageView = imageView1;
        bgImageView = imageView2;
    }
Bob
Reply With Quote
  #3 (permalink)  
Old June 6th, 2012, 08:07 AM
Registered User
Points: 23, Level: 1
Points: 23, Level: 1 Points: 23, Level: 1 Points: 23, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Now the images doesn't change ! same image again and again !
Reply With Quote
  #4 (permalink)  
Old June 6th, 2012, 08:12 AM
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
Default

Verify that your tags are set correctly in the .xib file. If you still can't figure out the problem, send the non-working project to
ipadhelper@me.com
and I will take a look at it for you.
Bob
Reply With Quote
The Following User Says Thank You to thepianoguy For This Useful Post:
jtown (June 6th, 2012)
Reply


Thread Tools
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
Views prashar SQL Language 1 December 13th, 2005 01:10 AM
multiple views cbodapati All Other Wrox Books 0 December 10th, 2005 04:31 AM
converting Access 2000 views to Sql views matta Classic ASP Professional 1 January 26th, 2005 02:37 PM
Views or not ?? stagedancer SQL Server 2000 1 November 24th, 2004 02:08 PM
Views SAM GORDON SQL Server 2000 5 July 19th, 2003 08:14 AM



All times are GMT -4. The time now is 12:34 AM.


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