2012-02-21 9 views
0

私の実装ファイルにはコンパイルに間違いがありますが、私はそれらを理解できません。あなたの助けを前にありがとう。実装ファイル内のエラー

は、エラーメッセージをコメントしている:

実装ファイル:

#import "TNRViewController.h" 

@implementation TNRViewController //'@end' is missing in implementation context 

@synthesize myIcon, myBackground, bgImages, shrinkButton; 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
hasMoved = NO; 
    hasShrunk = NO; 
    currentBackground = 0; 

    bgImages = [[NSArray alloc] initWithObjects: 
       [UIImage imageNamed:@"WallPaper_01.png"], 
       [UIImage imageNamed:@"WallPaper_02.png"], 
       [UIImage imageNamed:@"WallPaper_03.png"], 
       [UIImage imageNamed:@"WallPaper_04.png"], 
       [UIImage imageNamed:@"WallPaper_05.png"], 
       nil]; 

    size = CGAffineTransformMakeScale(.25, .25); 
    translate = CGAffineTransformMakeTranslation(0,-100); 

    myBackground.image = [bgImages objectAtIndex:currentBackground]; 
} 

- (void)viewDidUnload 
{ 

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

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
} 

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
} 

- (void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 
} 

- (void)viewDidDisappear:(BOOL)animated 
{ 
    [super viewDidDisappear:animated]; 
} 

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

- (void)dealloc { 
    [myIcon release]; 
    [myBackground release]; 
    [shrinkButton release]; 
    [super dealloc]; 
} 

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
    UITouch *touch = [[event allTouches] anyObject]; 
    if (CGRectContainsPoint([myIcon frame], [touch locationInView:nil])); // if statement has empty body 
    { 
     if (hasMoved == YES && hasShrunk == YES) { 
      myIcon.transform = CGAffineTransformTranslate(size, 0, 0); 
      hasMoved = NO; 
    } 
     if (hasMoved == YES && hasShrunk == NO) { 
      myIcon.transform = CGAffineTransformMakeTranslation(0, 0); 
      hasMoved = NO; 
    } 
     myIcon.center = [touch locationInView:nil]; 
    } 

} 

- (IBAction)shrink:(id)sender { 
    if (hasShrunk) { 
     [shrinkButton setTitle:@"Shrink" forState:UIControlStateNormal]; 
    } else { 
     [shrinkButton setTitle:@"Grow" forState:UIControlStateNormal]; 
    } 

    if (hasShrunk == NO && hasMoved == NO) { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     myIcon.transform = size; 
     [UIView commitAnimations]; 
     hasShrunk = YES; 
    } 

    else if (hasShrunk == NO && hasMoved == YES) { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     myIcon.transform = CGAffineTransformScale(translate, .25, .25); 
     [UIView commitAnimations]; 
     hasShrunk = YES; 
    } 

    else if (hasShrunk == YES && hasMoved == YES) { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     myIcon.transform = CGAffineTransformScale(translate, 1, 1); 
     [UIView commitAnimations]; 
     hasShrunk = NO; 
    } 

    else { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     myIcon.transform = CGAffineTransformIdentity; 
     [UIView commitAnimations]; 
     hasShrunk = NO; 
    } 
} 

- (IBAction)move:(id)sender { 
    if (hasMoved == NO && hasShrunk == NO) { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     myIcon.transform = translate; 
     [UIView commitAnimations]; 
     hasMoved = YES; 
    } 
     else if (hasMoved == NO && hasShrunk == YES){ 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     myIcon.transform = CGAffineTransformTranslate(size, 0, -100); 
     [UIView commitAnimations]; 
     hasMoved = YES; 
    } 
     else if (hasMoved == YES && hasShrunk == YES){ 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     myIcon.transform = CGAffineTransformTranslate(size, 0, 0); 
     [UIView commitAnimations]; 
     hasMoved = YES; 
    } 
     else 
    { 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDuration:1.0]; 
     myIcon.transform = CGAffineTransformMakeTranslation(0, 0); 
     [UIView commitAnimations]; 
     hasMoved = YES; 
    } 
} 

- (IBAction)change:(id)sender { 
    currentBackground++; 
    if(currentBackground >= [bgImages count]) 
     currentBackground = 0; 

    [UIView beginAnimations:@"changeview" context:nil]; 
    [UIView setAnimationDuration:1]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

    if (currentBackground == 1) { 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; 

    if (currentBackground == 2) { 
     [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES]; 

    if (currentBackground == 3) { 
     [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 

    if (currentBackground == 4) { 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES]; 

     [UIView commitAnimations]; 
     [myBackground.image = [bgImages objectAtIndex:currentBackground]; //Expected identifier 

} 

ヘッダファイル:

#import <UIKit/UIKit.h> 

@interface TNRViewController : UIViewController 
{ 

    IBOutlet UIImageView *myIcon; 
    IBOutlet UIImageView *myBackground; 
    IBOutlet UIButton *shrinkButton; 

    NSArray *bgImages; 
    int currentBackground; 
    bool hasMoved; 
    bool hasShrunk; 

    CGAffineTransform translate; 
    CGAffineTransform size; 
} 

@property (retain, nonatomic)IBOutlet UIImageView *myIcon; 
@property (retain, nonatomic)IBOutlet UIImageView *myBackground; 
@property (retain, nonatomic)NSArray *bgImages; 
@property (retain, nonatomic)IBOutlet UIButton *shrinkButton; 

- (IBAction)shrink:(id)sender; 
- (IBAction)move:(id)sender; 
- (IBAction)change:(id)sender; 

@end 
+0

であるべきではあなたのquestiです本当にあるはずです: '' @end 'が実装コンテキストにない ''をどうやって修正するのですか? – sarnold

+0

はい、私はそれを修正する方法を理解することはできません。 – pdenlinger

答えて

1

ここでは、あなたのソースファイルにコメントエラーがあります。

まず:

@implementation TNRViewController //'@end' is missing in implementation context 

あなたが.mファイルの末尾に@endが欠落していることを意味します。

第二:

[myBackground.image = [bgImages objectAtIndex:currentBackground]; //Expected identifier 

は次のようになります。

myBackground.image = [bgImages objectAtIndex:currentBackground]; 

サード:

if (CGRectContainsPoint([myIcon frame], [touch locationInView:nil])); // if statement has empty body 

if (CGRectContainsPoint([myIcon frame], [touch locationInView:nil])) // Remove the semi column 
関連する問題