objective c - segment Controller selector error? -


i have problem segment controller on iphone when want change shape or color throw errors

  #import "bidviewcontroller.h" #import "bidquartzfunview.h" #import "bidconstants.h"   @interface bidviewcontroller ()  @end  @implementation bidviewcontroller  - (void)viewdidload {     [super viewdidload];     // additional setup after loading view, typically nib. }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  - (ibaction)changecolor:(id)sender {     uisegmentedcontrol *control = sender;     nsinteger index = [control selectedsegmentindex];      bidquartzfunview *funview = (bidquartzfunview *)self.view;      switch (index) {         case kredcolortab:             funview.currentcolor = [uicolor redcolor];             funview.userandomcolor = no;             break;         case kbluecolortab:             funview.currentcolor = [uicolor bluecolor];             funview.userandomcolor = no;             break;         case kyellowcolortab:             funview.currentcolor = [uicolor yellowcolor];             funview.userandomcolor = no;             break;         case kgreencolortab:             funview.currentcolor = [uicolor greencolor];             funview.userandomcolor = no;             break;         case krandomcolortab:             funview.userandomcolor = yes;             break;         default:             break;     } }  - (ibaction)changeshape:(id)sender {     uisegmentedcontrol *control = sender;     [(bidquartzfunview *)self.view setshapetype:[control selectedsegmentindex]];     if ([control selectedsegmentindex] == kimageshape)         _colorcontrol.hidden = yes;     else         _colorcontrol.hidden = no; }  @end 

error:

-[uiview setshapetype:]: unrecognized selector sent instance 0x767a0a0 2013-05-14 22:42:15.836 quartzfun[1014:c07] * terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[uiview setshapetype:]: unrecognized selector sent instance 0x767a0a0'

i guess not initialized bidquartzfunview properly, instead of this:

(bidquartzfunview *)self.view 

try this:

bidquartzfunview *funview = [[bidquartzfunview alloc] initwithframe:self.view.frame]]; 

then should respond setshapeview:

[funview setshapeview:[control selectedsegmentindex]; 

also don't forget add bidquartzfunview view:

[self.view addsubview:funview]; 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -