Wrox Programmer Forums
|
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 June 5th, 2012, 11:37 AM
Registered User
 
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];
}
 
Old June 5th, 2012, 01:07 PM
Friend of Wrox
 
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
 
Old June 6th, 2012, 08:07 AM
Registered User
 
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 !
 
Old June 6th, 2012, 08:12 AM
Friend of Wrox
 
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
The Following User Says Thank You to thepianoguy For This Useful Post:
jtown (June 6th, 2012)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Views prashar SQL Language 1 December 13th, 2005 02:10 AM
multiple views cbodapati All Other Wrox Books 0 December 10th, 2005 05:31 AM
converting Access 2000 views to Sql views matta Classic ASP Professional 1 January 26th, 2005 03:37 PM
Views or not ?? stagedancer SQL Server 2000 1 November 24th, 2004 03:08 PM
Views SAM GORDON SQL Server 2000 5 July 19th, 2003 08:14 AM





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