语义问题&解析问题:缺少方法声明的上下文&预期的方法体

时间:2012-06-19 20:21:05

标签: iphone

获得语义问题&解析问题:缺少方法声明的上下文&用于暂停和恢复UIImageviewanimation方法的预期方法体。在MainViewController.h文件中声明了这两个方法

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

- (void)resumeLayer:(CALayer *)layer;
- (void)PauseLayer:(CALayer *)layer;

@interface MainViewController : UIViewController
@property (nonatomic, retain) UIToolbar *toolbar;
@property (strong)AVAudioPlayer *audioPlayer;
@property (nonatomic, retain) NSTimer * timer;
m文件中的

方法

-(void)pauseLayer:(CALayer*)layer
{
CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
}

-(void)resumeLayer:(CALayer*)layer
{
CFTimeInterval pausedTime = [layer timeOffset];
layer.speed = 1.0;
layer.timeOffset = 0.0;
layer.beginTime = 0.0;
CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
layer.beginTime = timeSincePause;
 }

我很困惑我在这里没有定义的内容。

感谢您的帮助。

1 个答案:

答案 0 :(得分:3)

您应该将方法定义放在@interface和@end块

@interface MainViewController : UIViewController

@property (nonatomic, retain) UIToolbar *toolbar;
@property (strong)AVAudioPlayer *audioPlayer;
@property (nonatomic, retain) NSTimer * timer;

- (void)resumeLayer:(CALayer *)layer;
- (void)PauseLayer:(CALayer *)layer;

@end