Why not just create a generic segue and use that? It doesn't need to be connected to a cell or a UI control. That way your code will work as long as the segue identifier is correct.
Segues in uitableView emebed in ViewController using swrevealviewcontroller
-
19-07-2023 - |
سؤال
I'm developing an iOS app and I have a big problem...
I need to have a tableview inside viewController (that's why I can not use UiTableViewController) and I can't use static cells. I solved that creating a NSMutableArray and loading each cell in my cellForRowAtIndexPath.
So, what's my problem?
In swrevealviewcontroller tutorials (like http://www.appcoda.com/ios-programming-sidebar-navigation-menu/) they use segues for navigation when pushing cells, so, How can I create segues dinamically?
I tried to use
MyNewVC *myNewVc=[self.storyboard instantiateViewControllerWithIdentifier:@"homeVC"];
[self.navigationController pushViewController:myNewVc animated:YES];
but it doesn't work.
Thanks!!
المحلول
نصائح أخرى
You need to link the segues from the view controller to their destinations then use the view controller's preformSegueWithIdentifier: method. See this: Understanding performSegueWithIdentifier
[self presentViewController:magnifiedVC animated:YES completion:^{
//place block to run here, such as assigning properties
}];
It is not a segue, but another way of keeping track of view controllers. you can then dismiss the destination view controller by doing this in a destination view controller method:
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
This means you will have instantiate the destination view controller in your presenting view controller, which you do not need to with a segue I afaik.
EDIT1:
In that case, you can use instantiateViewControllerWithIdentifier:
to allocate and prepare the view controller, and then use performSegueWithIdentifier:
. you will then need to use core data or plists to store the state of each view controller everytime you perform a segue to prevent the sending controller from being unloaded and released and losing its data. you can do this in the prepareForSegue:
.
note: you can not use storyboard instantiated view controllers for use on the navigation controller