ios - Xcode 5: It is giving me error messages when I add an action to my button -


here .h view controller file:

#import <uikit/uikit.h>  @interface zkgamecontroller : uiviewcontroller  {     iboutlet uiimageview *playersprite; iboutlet uibutton *rightbutton; iboutlet uibutton *leftbutton;  nstimer *animationtimer;  }   [rightbutton addtarget:self action:@selector(startleftanimation)     forcontrolevents:uicontroleventtouchdown]; [rightbutton addtarget:self action:@selector(stopanimation)   forcontrolevents:uicontroleventtouchupinside]; [rightbutton addtarget:self action:@selector(stopanimation)   forcontrolevents:uicontroleventtouchupoutside];   [leftbutton addtarget:self action:@selector(startleftanimation)     forcontrolevents:uicontroleventtouchdown]; [leftbutton addtarget:self action:@selector(stopanimation)   forcontrolevents:uicontroleventtouchupinside]; [leftbutton addtarget:self action:@selector(stopanimation)   forcontrolevents:uicontroleventtouchupoutside];   - (void)stopanimation; - (void)frontbarrelanimation; - (void)barrelstartdown; - (void)startleftanimation; - (void)startrightanimation; - (void)animateleft; - (void)animateright;  @end 

it gives me error messages on "leftbutton addtarget:self..." blah blah blah. have search why , have found no reason says "expected identifier or'(', use of undeclared identifier "self" , "leftbutton" , same thing right button.

here .m file if helps: #import "zkgamecontroller.h"

@interface zkgamecontroller ()  @end  @implementation zkgamecontroller  - (void)startleftanimation {     animationtimer = [nstimer scheduledtimerwithtimeinterval:.01 target:self     selector:@selector(animateleft) userinfo:nil repeats:yes]; }  - (void)startrightanimation {      animationtimer = [nstimer scheduledtimerwithtimeinterval:.01 target:self     selector:@selector(animateright) userinfo:nil repeats:yes]; }   - (void)stopanimation {     if(animationtimer != nil)     {         [animationtimer invalidate];         animationtimer = nil;     } }  - (void)animateleft {     playersprite.center = cgpointmake(playersprite.center.x - 1, playersprite.center.y); }  - (void)animateright {     playersprite.center = cgpointmake(playersprite.center.x + 1, playersprite.center.y); }       - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {         // custom initialization     }     return self; }  - (void)viewdidload {     [super viewdidload];     // additional setup after loading view. }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  /* #pragma mark - navigation  // in storyboard-based application, want little preparation before     navigation - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {     // new view controller using [segue destinationviewcontroller].     // pass selected object new view controller. } */  @end 

i have linked of image views , buttons correct things gives me messages. if have suggestions please help.

cut , paste add target calls viewdidload method after [super viewdidload]; in .m file


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -