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 February 4th, 2011, 12:05 AM
Registered User
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 3 pageControl problem

hey there - i'm sure this is something simple, but this problem is driving me mad... I have coded the example that switches between images, and the app compiles fine and the first image displays fine - but the app crashes with the following error (when you click on the pageControl to switch between views)

2011-02-03 22:54:37.062 TimsView[1590:207] -[TimsViewViewController pageTurning:]: unrecognized selector sent to instance 0x5256900

My code is below - i really hope someone can help!

.m file
Code:
#import "TimsViewViewController.h"

@implementation TimsViewViewController

@synthesize pageControl;
@synthesize imageView1, imageView2;


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	
	[imageView1 setImage:[UIImage imageNamed:@"uk-georgia.gif"]];
	tempImageView = imageView2;
	
	[imageView1 setHidden:NO];
	[imageView2	setHidden:YES];
	
	[pageControl addTarget:self
					action:@selector(pageTurning:)
		  forControlEvents:UIControlEventValueChanged];
	
	[super viewDidLoad];
}

- (void)  : (UIPageControl *) pageController {
	NSInteger nextPage = [pageController currentPage];
	switch (nextPage) {
		case 0:
			[tempImageView setImage:[UIImage imageNamed:@"uk-georgia.gif"]];
			break;
		case 1:
			[tempImageView setImage:[UIImage imageNamed:@"UNKG0001.gif"]];
			break;
		case 2:
			[tempImageView setImage:[UIImage imageNamed:@"UKST0109.gif"]];
			break;
		case 3:
			[tempImageView setImage:[UIImage imageNamed:@"UNST0110.gif"]];
			break;
		case 4:
			[tempImageView setImage:[UIImage imageNamed:@"us-gu.gif"]];
			break;
			
		default:
			break;
	}
	
	if (tempImageView.tag == 0) {
		tempImageView = imageView2;
		bgImageView = imageView1;
	}
	else {
		tempImageView = imageView1;
		bgImageView = imageView2;
	}

	
	[UIView beginAnimations:@"flipping view" context:nil];
	[UIView setAnimationDuration:0.5];
	[UIView	setAnimationCurve:UIViewAnimationCurveEaseInOut];
	[UIView	setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:tempImageView cache:YES];	
	
	[tempImageView setHidden:YES];
	
	[UIView commitAnimations];
	
	[UIView beginAnimations:@"flipping view" context:nil];
	[UIView	setAnimationDuration:0.5];
	[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
	[UIView	setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:bgImageView cache:YES];
	
	[bgImageView setHidden:NO];
	
	[UIView commitAnimations];
	
}


- (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.
}

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


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

@end
and .h definitions:

[CODE]#import <UIKit/UIKit.h>

@interface TimsViewViewController : UIViewController

{
IBOutlet UIPageControl *pageControl;
IBOutlet UIImageView *imageView1;
IBOutlet UIImageView *imageView2;
UIImageView *tempImageView, *bgImageView;

}

@property (nonatomic, retain) UIPageControl *pageControl;
@property (nonatomic, retain) UIImageView *imageView1;
@property (nonatomic, retain) UIImageView *imageView2;


@end/CODE]
 
Old February 4th, 2011, 09:02 AM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

If the code you provided matches your project code, then your pageTurning method doesn't have a signature.
The code you provided is
Code:
- (void)  : (UIPageControl *) pageController { 
…etc.
and should be

Code:
-(void)pageTurning:(UIPageControl *) pageController  {
…etc.
When you assign the selector, this is the name you assign. At runtime it looks for this and cannot find it, so it crashes. Since the runtime is dynamic it will not find this error during while compiling.
Bob
 
Old February 10th, 2011, 10:25 PM
Registered User
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much - i must have deleted this by accident. DOH..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in chapter 1 chrispynegar BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 0 May 6th, 2009 06:37 AM
Chapter 2 problem jnbutler BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 1 June 1st, 2007 08:54 PM
Chapter 2 problem stzd8 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 November 6th, 2006 07:08 PM
Chapter 5 Problem gogeo BOOK: Beginning Access 2003 VBA 1 October 10th, 2005 10:34 AM





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