Storyboard Segue From View Controller to Itself
I developed a method to create a segue using a phantom button. I believe it will solve your problem. You can read about it in my answer here.
Can you define a Segue in the storyboard to self?
Yes you can do it. Add a hidden button in view controller and drag & drop segue self view controller.
Xcode 6 - Push segue to same view controller
As suggested, I don't think a segue will work. Instead you can push a new instance of the same view controller programmatically, which will have the same effect as performing the segue. The difference is that segue delegate methods like prepareForSegue won't be called.
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MyViewController *vc = [[MyViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
check the segue used to open viewController in the viewController itself
To do that instead of performing your Segue on a button click in storyboard, create a segue from your viewcontroller to your other view controller. then when you want to go to the next view controller call below from your button click or any other action event.
self.performSegue(withIdentifier: "accountSegue", sender: self)
This will automatically call your prepareForSegue method and your if statement will execute.
Why does View Controller Shift in Storyboard on Button Segue
You need to set fullscreen style manually if select model style,
a fullscreen option did not show in Push type, you must use Navigation Controller if you want to set fullscreen for Push
https://i.stack.imgur.com/rg20Y.png
how to perform push segue to certain view controller in navigation stack in the different storyboard?
Create a reference id for the ViewController you want to push
In the second storyboard
Choose the ViewController on the interface builder
Assign "Storyboard ID" to it (for ex. SecondVC)
Back to the main storyboard
choose the storyboard reference to the "second" storyboard and add the VC id (SecondVC) in the "Referenced ID" field
Segue To Same View Controller Programmatically?
Set an identifier for your UIViewController in the storyboard. Then instantiate it using that my identifier:
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "someViewController")
If you want to set variables, make sure to cast vc
. This example will help you know how many levels deep you are on the same controller:
let vc = storyboard.instantiateViewController(withIdentifier: "rootViewController") as! MyRootViewController
vc.level = self.level + 1
Related Topics
How to Use Icloud to Sync the Nsuserdefaults Plist File
Detect When a Webview Video Becomes Fullscreen on iOS8
Create Uicollectionviewcell Subclass with Xib
Swiftui Datepicker Jumps Between Short and Medium Date Formats When Changing the Date
Swift If Statement - Multiple Conditions Separated by Commas
Uipopovercontroller Dealloc Reached While Popover Is Still Visible
How to Create a Release Build in Xcode
How to Correctly Subclass Uicontrol
How to Make Both Header and Footer in Collection View with Swift
Xcode 4.2 Jumps to Main.M Every Time After Stopping Simulator
Get Search Bar in Navigation Bar in Swift
Getting Device Id or MAC Address in iOS