Ios 实现文件中的错误
我的实现文件中有一些错误使我无法编译,但我无法找出它们。提前感谢你的帮助 已注释掉错误消息: 实施文件:Ios 实现文件中的错误,ios,Ios,我的实现文件中有一些错误使我无法编译,但我无法找出它们。提前感谢你的帮助 已注释掉错误消息: 实施文件: #import "TNRViewController.h" @implementation TNRViewController //'@end' is missing in implementation context @synthesize myIcon, myBackground, bgImages, shrinkButton; - (void)didReceiveMemoryWa
#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
#导入
@接口TNRViewController:UIViewController
{
IBUIImageView*我的图标;
ibuiimageview*myBackground;
IBUIButton*收缩按钮;
NSArray*bg图像;
背景;
布尔搬家了;
布尔·哈什伦克;
CG仿射翻译;
CG仿射变换大小;
}
@属性(保留,非原子)IBUIImageView*myIcon;
@属性(保留,非原子)IBUIImageView*myBackground;
@属性(保留,非原子)NSArray*bgImages;
@属性(保留,非原子)IBUIButton*收缩按钮;
-(iAction)收缩:(id)发送方;
-(iAction)移动:(id)发送方;
-(iAction)更改:(id)发件人;
@结束
以下是您在源文件上注释的错误
第一:
@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
您的问题真的应该是:如何修复
“@end”在实现上下文中丢失了?是的,我不知道如何修复它。