Instead of push segue how to replace view controller (or remove from navigation stack)?
You could use a custom segue: to do it you need to create a class subclassing UIStoryboardSegue (example MyCustomSegue), and then you can override the "perform" with something like this
-(void)perform {
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
UINavigationController *navigationController = sourceViewController.navigationController;
// Pop to root view controller (not animated) before pushing
[navigationController popToRootViewControllerAnimated:NO];
[navigationController pushViewController:destinationController animated:YES];
}
At this point go to Interface Builder, select "custom" segue, and put the name of your class (example MyCustomSegue)
In swift
override func perform() {
if let navigationController = self.source.navigationController {
navigationController.setViewControllers([self.destination], animated: true)
}
}
Remove view controller from navigation stack after push segue (using Storyboard segues)
Just replace the rootViewController of your UIWindow
.
controllerA and controllerB can be any Viewcontroller
-Class you want.
You could use a simple UITableViewController
for the Loginpage and then replace the rootViewController of your UIWindow
with a UINavigationController
holding controllerB
[UIView transitionFromView:controllerA.view
toView:controllerB.view
duration:0.65f
options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionTransitionCrossDissolve)
completion:^(BOOL finished){
delegate.window.rootViewController = controllerB;
}];
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
How to Dismiss Model View Controller before push?
I think you can implement in that way:
- when you at screen 3 you want push screen 2. You will dismiss screen 3 and call a delegate back screen 1.
- And from screen1 you will push view to screen2.
You can see my demo for my idea: Demo Pushview Swift
DemoPushViewObj
How to detect whether show (push) segue navigation controller is pressed?
You can work on the viewWillDisappear method on your second view controller like this:
- (void)viewWillDisappear:(BOOL)animated
{
if(self.isMovingFromParentViewController){
NSLog(@"Controller being popped");
}
}
In this case, self.isMovingFromParentViewController will be true if the controller is being popped.
You can also check for self.isMovingToParentViewController on viewWillAppear for example, to check that the controller is being pushed.
Also self.isBeingDismissed and self.isBeingPresented are available and refer to when a controller is being presented/dismissed (modally).
Related Topics
How to Style Uitextview to Like Rounded Rect Text Field
How to Hide a Navigation Bar from First Viewcontroller in Swift
Center Content of Uiscrollview When Smaller
iPhone "Slide to Unlock" Animation
Xcode 8 Shows Error That Provisioning Profile Doesn't Include Signing Certificate
Get the Right Color in iOS7 Translucent Navigation Bar
Saving Email/Password to Keychain in iOS
How to Use Autolayout to Set Constraints on My Uiscrollview
Formatting a Uitextfield for Credit Card Input Like (Xxxx Xxxx Xxxx Xxxx)
What Does "@Private" Mean in Objective-C
Iphone: Where the .Dsym File Is Located in Crash Report
Uilabel Wrong Word Wrap in iOS 11
Differences Between Udid and Uuid
What Is the Life Cycle of an iPhone Application