iphone - Load UIViewController on another UIViewController in UIStoryboard from xib -
i have uiviewcontroller(say a). separate nib file loaded popup on view controller. when popup closed clicking uibutton, want load view controller(say b) in uistoryboard. uiviewcontrollers in storyboard.
i tried delegates pattern. delegate method returns self.storyboard nil.
please suggest how handle (either performsegue b or pushing new instance of b on navigation controller nib file)
here code used delegate:
**in customviewnewprescription.h file:** @class customviewnewprescription; @protocol customviewnewprescriptiondelegate <nsobject> -(void)savecustomviewnewprescription; @end @interface customviewnewprescription : uiview{ id<customviewnewprescriptiondelegate>delegate; } @property(nonatomic,strong) id<customviewnewprescriptiondelegate>delegate; **in .m:** - (ibaction)btncancel:(uibutton *)sender{ [self.delegate savecustomviewnewprescription]; } delegate synthesized , initialised. **in addnewrx.h:** @interface addnewrx : uiviewcontroller<customviewnewprescriptiondelegate>{ } **in addnewrx.m:** -(void)savecustomviewnewprescription{ //either self performseguewithidentifier .... (or) rxviewcontroller *obj1 = [[self.navigationcontroller storyboard] instantiateviewcontrollerwithidentifier:@"rxviewcontroller"]; [self.navigationcontroller pushviewcontroller:obj1 animated:yes]; }
in savecustomviewnewprescription, self.storyboard giving nil values
please suggest how load view controller in savecustomviewnewprescription.
instead of:
rxviewcontroller *obj1 = [[self.navigationcontroller storyboard] instantiateviewcontrollerwithidentifier:@"rxviewcontroller"];
try:
uistoryboard *yourstoryboard = [uistoryboard storyboardwithname:@"mainstoryboard" bundle:nil]; rxviewcontroller *obj1 = [yourstoryboard instantiateviewcontrollerwithidentifier:@"rxviewcontroller"];
Comments
Post a Comment