Reputation: 143
I have a project and I am having trouble maintaining a navigation controller (which I added through the interface builder). I want to set up a hierarchy because it is saying the views are not added to the window hierarchy. I can move between one view using performSegueWithIdentifier, but using it a second time doesn't work. The problem is it won't allow me to move from one view to another. I have read stuff about messing with the appdelegate or add performForSegue, but I don't know how to using it.
Any suggestions for if I had three views connected like 1 -> 2 -> 3? 1 and 2 would have performSegueWithIdentifier.
Please and thank you!
Here is my storyboard: http://s1370.photobucket.com/user/sean_cleveland1/media/Untitled_zpsc9022523.png.html?o=0
Here is my performSegueWithIdentifier functions:
//Used in FirstVC.
[self performSegueWithIdentifier: @"firstToSecond" sender: self];
//Used in SecondVC... this doesn't work!
[self performSegueWithIdentifier: @"secondToThird" sender: self];
Upvotes: 2
Views: 223
Reputation: 23271
First define your third view identifier
- (void)segue
{
[self performSegueWithIdentifier:@"mySegue" sender:self];
}
for only do any condition or operation use below method
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString:@"mySegue"]) {
}
}
i created simple sample project for you
https://github.com/iDevAndroid/NavigationSample
try with this. because your are perform model transaction after next line your are using dismiss the model.
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self becomeFirstResponder];
[self dismissViewControllerAnimated:YES completion:^{
[self emailDelivaryedSuccessfully];
];
}
-(void)emailDelivaryedSuccessfully{
[self performSegueWithIdentifier: @"secondToThird" sender: self];
}
Upvotes: 1
Reputation: 7474
Just Control + drag from "Pop to Main Screen" UIButton
to Exit (green button at bottom of scene)
select unwind method declared in first screen with title "Main"
e.g.
-(IBAction)customUnwind:(UIStoryboardSegue *)sender
{
NSLog(@"Unwind successful");
}
Upvotes: 2
Reputation: 12023
You don't need to use performSegueWithIdentifier:
if you are doing it in Storyboard, just comment the code which says performSegueWithIdentifier:
and prepareForSegue:
method in your code and try.
If you are using performSegueWithIdentifier:
then you need to implement prepareForSegue:
method also.
ex.
[self performSegueWithIdentifier: @"firstToSecond" sender: self];
//prepareforsegue method
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString:@"firstToSecond"]) {
SecondViewController *destinationController = [segue destinationViewController];
//set data if any
}
}
Upvotes: 0