Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6037895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:08:25+00:00 2026-05-23T06:08:25+00:00

Have the following code: #import UsingViewsViewController.h @implementation UsingViewsViewController @synthesize pageControl; @synthesize imageView1, imageView2; –

  • 0

Have the following code:

#import "UsingViewsViewController.h"

@implementation UsingViewsViewController
@synthesize pageControl;
@synthesize imageView1, imageView2;

- (void)dealloc
{
    [pageControl release];
    [imageView1 release];
    [imageView2 release];
    [super dealloc];
}

 - (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


// Implement viewDidLoad to do additional setup after loading the view, typically from a       nib.
- (void)viewDidLoad
{
    // --- initialize the first imageview to display an image---
    [imageView1 setImage:[UIImage imageNamed:@"iMac_old.jpeg"]];
    tempImageView = imageView2;

    //--- make the first imageview visible and hide the second---
    [imageView1 setHidden:NO];
    [imageView2 setHidden:YES];

    //--- Add the event handler for the page controller ---
    [pageControl addTarget:self 
                    action:@selector(pageTurning:) 
           forControlEvents:UIControlEventValueChanged];
    /*
    UIActionSheet *action =
    [[UIActionSheet alloc]
     initWithTitle:@"Title of action sheet" 
     delegate:self 
     cancelButtonTitle:@"OK" 
     destructiveButtonTitle:@"Delete message" 
     otherButtonTitles:@"Option 1",@"Option 2", nil];
    [action showInView:self.view];
    [action release];
     */

     /*
    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"Hello" 
                          message:@"This is an alert view" 
                          delegate:self 
                          cancelButtonTitle:@"OK" 
                          otherButtonTitles:@"Option 1", @"Option 2", nil];
                          [alert show];
                          [alert release];*/
                          [super viewDidLoad];

}

//--- When the page controls value is changed---
- (void)pageTurning: (UIPageControl *)pageController {
    //--- get the page number you can turning to ---
    NSInteger nextPage = [pageController currentPage];
    switch (nextPage) {
        case 0:
            [tempImageView setImage:
            [UIImage imageNamed:@"iMac_old.jpeg"]];
            break;
        case 1:
            [tempImageView setImage:
            [UIImage imageNamed:@"iMac.jpeg"]];
            break;
        case 2:
            [tempImageView setImage:
            [UIImage imageNamed:@"Mac8100.jpeg"]];
            break;
        case 3:
            [tempImageView setImage:
            [UIImage imageNamed:@"MacPlus.jpeg"]];
            break;
        case 4:
            [tempImageView setImage:
             [UIImage imageNamed:@"MacSE.jpeg"]];
            break;
        default:
            break;
    }

    //--- Switch the two imageviews---
    if (tempImageView.tag==0) {
        //--- imageView1---
        tempImageView = imageView2;
        bgImageView = imageView1;
    }
    else {
        //---imageView2---
        tempImageView = imageView1;
        bgImageView = imageView2;
    }

    //---animate the two views flipping---
    [UIView beginAnimations:@"flipping view" 
     context:nil];
     [UIView setAnimationDuration:0.5];
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
     [UIView setAnimationTransition:tempImageView];
     cache:YES];

    [tempImageView setHidden:YES];

    [UIView commitAnimations];

    [UIView beginAnimations:@"flipping view" 
                    context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:tempImageView];
cache:YES];

    [bgImageView setHidden:NO];

    [UIView commitAnimations];

}



/*
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"%d", buttonIndex);
}
*/

/*
-(void)actionSheet:(UIActionSheet *)actionSheet      clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"%d", buttonIndex);
}
*/


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

-     (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

My problem is that Xcode is telling me that tempImageView is an unspecified identifier and won’t compile.

Does it need to be declared as a variable? If so, where should I declare it, and what type should it be? Does it need to be declared in the header file too?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:08:26+00:00Added an answer on May 23, 2026 at 6:08 am

    you need to declare that variable.
    In your .h file add:
    (in your interfase)

    UIImageView *tempImageView;
    

    then in your .m file edit this line: @synthesize imageView1, imageView2;
    change it to: @synthesize imageView1, imageView2, tempImageView ;

    Hope it helps!


    UPDATE

    Forgot memory related stuff.. Add in your - (void)dealloc:

    [imageView2 release];
    [tempImageView release]; //ADD THIS LINE
    [super dealloc];
    

    UPDATE

    Do the same with bgImageView

    In your .h file add:
    (in your interfase)

    UIImageView *bgImageView;
    

    then in your .m file edit this line: @synthesize imageView1, imageView2, tempImageView;
    change it to: @synthesize imageView1, imageView2, tempImageView, bgImageView;

    Add in your - (void)dealloc:

    [imageView2 release];
    [tempImageView release];
    [bgImageView release]; //ADD THIS LINE
    [super dealloc];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: import java.net.InetAddress; public class lookup { public static void
I have the following code: import com.apple.dnssd.*; public interface IServiceAnnouncer { public void registerService();
I have the following Python code: import xml.dom.minidom import xml.parsers.expat try: domTree = ml.dom.minidom.parse(myXMLFileName)
I have following code import sys from ctypes import * from ctypes.util import find_library
I have the following code: #import <Foundation/Foundation.h> #import ServerRequest.h // works even though this
I have the following code: import string def translate_non_alphanumerics(to_translate, translate_to='_'): not_letters_or_digits = u'!#%\'()*+,-./:;<=>?@[\]^_`{|}~' translate_table
I have the following code import smtplib from email.mime.text import MIMEText smtpserver = 'smtp.gmail.com'
I have the following code: import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; public
I have the following code: import string import random d =[random.choice(string.uppercase) for x in
I have the following code: import matplotlib.pyplot as plt cdict = { 'red' :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.