2

I want to pass data between storyboard with tabBar and external xib . I tried to use prepareforsegue but the method didn't call or if i define a segue this didn't recognize this .

my code is :

 UIStoryboard *storyborad = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
       UIViewController *view = [storyborad instantiateViewControllerWithIdentifier:@"<identifier>"];
        [self.navigationController setNavigationBarHidden:YES];
        [self.navigationController pushViewController:view animated:YES];
     // [self performSegueWithIdentifier:@"try" sender:self]; // tried to use performSegueWithIdentifier but this recognize identifier

and the prepareforsegue method code :

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

BIDViewController *viewControllerView = segue.destinationViewController;
viewControllerView.isViewPushed=1;
NSLog(@"prepareForSegue");
rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Have you set the identifier in the xib? – Alex Oct 24 '13 at 11:39
  • You have a storyboard and you want to push to a nib file, no? So you can use [self performSegueWithIdentifier@"try" sender:self] but you need to set that identifier ("try") in the destination nib. After you have set the identifier in the nib, prepareSegue function will be called. – Alex Oct 24 '13 at 12:03
  • yes but its goes like that : external nib --> view in storyboard so what i did was define (give them identifier) both the nib itself (in the storyboard) and the segue but this still wrote "Receiver () has no segue with identifier" – user2915374 Oct 24 '13 at 12:49
  • Take a look of this thread because they had the same issue, and let us know: http://stackoverflow.com/questions/12996504/receiver-viewcontroller-has-no-segue-with-identifier-infoseg – Alex Oct 24 '13 at 13:01
  • This doesn't work .. i want to add something that could help the external nib is outside storyboard ( its belong to class that have own nib file ) i succeed to open view in the storyboard but i need to pass data too maybe i dont set the segue identifier right ? – user2915374 Oct 24 '13 at 13:24
  • Yes, check that you have set right the view controller in that view and the identifiers – Alex Oct 24 '13 at 13:33
  • can i set the view controllers ? if yes how i set identifier ? – user2915374 Oct 24 '13 at 13:57
  • Setting the view controllers is go to the view controller in your view and change custom class to your class, and set the identifier there as well. http://i.stack.imgur.com/EJJpo.png – Alex Oct 24 '13 at 14:05
  • this what i did , when i pushed this open the view and the data not pass ( i use in this : UIViewController *view = [storyborad instantiateViewControllerWithIdentifier:@"myIdentifier"]; and than push the view ) but if i set segue identifier and use : [self performSegueWithIdentifier:@"MySegueIdentifier" sender:self] this wrote the has no segue with identifier – user2915374 Oct 24 '13 at 14:31

1 Answers1

0

Instead of this:

UIStoryboard *storyborad = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *view = [storyborad instantiateViewControllerWithIdentifier:@"<identifier>"];
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController pushViewController:view animated:YES];

Try this:

UIStoryboard *storyborad = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
BIDViewController *view = [storyborad instantiateViewControllerWithIdentifier:@"myIdentifier"];
view.isViewPushed = 1;
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController pushViewController:view animated:YES];
Alex
  • 1,061
  • 10
  • 14
  • the view dont connection to the class that have this property – user2915374 Oct 24 '13 at 15:12
  • sorry for double post , but the problem still there – user2915374 Oct 25 '13 at 11:05
  • Can you check if view from BIDViewController is nil? – Alex Oct 25 '13 at 12:18
  • Put a breakpoint after init it and see what is the value for the view or NSLog(@"%@", view) after initialise it – Alex Oct 25 '13 at 13:47
  • its not nil . if i push the view i can pass data or i have prepareForSegue ? – user2915374 Oct 25 '13 at 14:07
  • someone have any idea what i need to do ? – user2915374 Oct 27 '13 at 12:20
  • You can pass data using push. How have you declared isViewPushed property in BIDViewController? Can you show that code? – Alex Oct 28 '13 at 10:47
  • in the BIDViewController.h : @property NSInteger isViewPushed; in BIDViewController.m : < - (void)viewDidLoad { if(isViewPushed==1) { [self.tabBarController setSelectedIndex:1]; isViewPushed=isViewPushed*-1; } } > – user2915374 Oct 29 '13 at 12:55
  • Check before sending (before pushViewController and in viewDidload in BIDViewController if the memory address is the same, doing po view and po self – Alex Oct 29 '13 at 14:06
  • I not sure that i check it right , but they no have the save memory address – user2915374 Oct 29 '13 at 16:41
  • Do you have another view property in your class? Anyways, check this: http://stackoverflow.com/questions/8926606/performseguewithidentifier-vs-instantiateviewcontrollerwithidentifier and this: http://stackoverflow.com/questions/8348109/how-can-i-manually-switch-between-uiviewcontrollers-in-storyboard – Alex Oct 29 '13 at 17:00
  • I have another view property in BIDViewController . the links not help so much because like i told you before , one view in storyboard and the second belong to class that have .h , .m and xid file (in the links they have 2 view in storyboard) i push the view that in storyboard from the class that have own xid file – user2915374 Oct 29 '13 at 17:22