iphone - MultipleControllers in one view -


i trying add 2 view controllers 1 controller.

i created view based application called "multipleviews". after add 2 controller classes "redview.h" , "blueview.h" own xibs. able add views of both controllers "mutipleviewsviewcontroller" method [self.view addsubview:red.view]. both views displayed properly. problem when add button red , blue controllers. whenever click button says unrecognized selector sent instance though linked buttons functions properly. missing here?

here code:

multipleviewsviewcontroller.h

#import <uikit/uikit.h>  @interface mutipleviewsviewcontroller : uiviewcontroller {  }  @end 

mutipleviewsviewcontroller.m

-

 (void)viewdidload {     [super viewdidload];      redview *red = [[redview alloc]init];      red.view.frame = cgrectmake(0, 0, 320, 240);      [self.view addsubview:red.view];      blueview *blue = [[blueview alloc]init];      blue.view.frame = cgrectmake(0, 240, 320, 240);      [self.view addsubview:blue.view];    } 

redview.h

#import <uikit/uikit.h>   @interface redview : uiviewcontroller {  }  -(ibaction)buttonpressed;  @end 

blueview.h

#import <uikit/uikit.h>   @interface blueview : uiviewcontroller {  }  -(ibaction)buttonpressed;  @end 

the buttons linked buttonpressed method through ib. message when click button in red view is:

mutipleviews[1865:207] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[redview buttonpressed]: unrecognized selector sent instance 0x4e12500' 

sorry not being clear earlier.



the ibactions typically take input parameter of type id. buttonpressed action should like

-(ibaction)buttonpressed:(id)sender; 

when action called, reference control calls (in case button) passed.

when calling programatically, can send controller's object (self) it.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -