Tags down


how to replace view controllers instead push more segue

By : Thanh Tân
Date : September 15 2020, 04:00 AM
wish helps you I understand you want to change the root view controller. Changing root view controller clears the navigation stack and deallocates the memory taken by VCs.
code :
  // paste this in appDelegate or make it as an extension 

  func makeRootVC(storyBoardName : String, vcName : String) {

        let vc = UIStoryboard(name: storyBoardName, bundle: Bundle.main).instantiateViewController(withIdentifier: vcName)
        let nav = UINavigationController(rootViewController: vc)
        nav.navigationBar.isHidden = true
        self.window?.rootViewController = nav
        let options: UIView.AnimationOptions = .transitionCrossDissolve
        let duration: TimeInterval = 0.6
        UIView.transition(with: self.window!, duration: duration, options: options, animations: {}, completion: nil)

Share : facebook icon twitter icon

Instead of push segue how to replace view controller (or remove from navigation stack)?

By : Ryan Bacares
Date : March 29 2020, 07:55 AM
I wish this help you 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
code :
-(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];    

How can I pass data between two View Controllers in a Navigation Controller, with two Push Segue?

By : niyam
Date : March 29 2020, 07:55 AM
Does that help I have two view controllers inside a Navigation Controller. In the first view controller I have two buttons. Both of them call the second view controller using a Push segue, but: , Assign Identifier to each segue in storyboard and implement
code :
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"YOUR_SEGUE_NAME_HERE"])
        // Get reference to the destination view controller
        YourViewController *vc = [segue destinationViewController];
        [vc setDelegate:self];
        // Pass any objects to the view controller here, like...
        [vc setMyObjectHere:object];
@protocol SomethingDelegate <NSObject>
- (void)dateChanged:(NSString *)dateStr; //you can use NSDate as well

@interface ViewController2 : UIViewController

@property(weak) id<SomethingDelegate> delegate;

-(void) OkClicked{

    [_delegate dateChanged:@"YOUR_DATE_VALUE"];
#import "SecondViewController.h"
@interface FirstViewController : UIViewController<SomethingDelegate>
  -(void)dateChanged:(NSString *)dateStr{

        // do whatever you need with dateStr
//also i made some change in prepareForSegue method

iOS: Programmatically Push Segue to Multiple View Controllers

By : user2043189
Date : March 29 2020, 07:55 AM
wish of those help You don't need any code to implement the basic segues.
In your story board ensure that your original view controller is embedded in a navigation controller (Select the original View and select Edit->Embed in->Navigation Controller).

Cannot pass UIImageView between view controllers using a push segue

By : vijaya lakshmi
Date : March 29 2020, 07:55 AM
it helps some times I'm trying to pass a UIImageView from a Master View Controller to a Detailed View Controller using a Push Segue. Everything loads fine on the Master View Controller, and I've created a push segue using the UIImageView on the Master View Controller. Here's my Master View Controller - , Try changing inside your prepareForSegue:, instead of using:
code :
playlistDetailController?.image = UIImage(named: coverImage)
playlistDetailController.image = coverImage.image

Swift segue - Presenting view controllers on detached view controllers is discouraged

By : celia00
Date : March 29 2020, 07:55 AM
around this issue I had a same warning and fixed it by moving code to -viewDidAppear. One thing you should be aware is that -viewDidLoad is called only once while -viewDidAppear maybe called multiple times if page becomes visible so you need to add additional mechanism to skip performing segue again.
Related Posts Related Posts :
  • Confusion around reference type variable in Swift
  • SwiftUI: How do style Text view with different font and colour on string subranges
  • RealityKit – How to set a ModelEntity's transparency?
  • How to add 3D shapes in Swift UI?
  • how we can use 2 UIPicker on the same controller?
  • How can i center a placeholder text in a TextField Swiftui
  • sign in with firebase ios email
  • Custom intialiser on Primitive types for JSONDecoder
  • Beginner question- How do I control isUserInteractionEnabled status of a button remotely in swift?
  • Swift 4 / Xcode 10 Error message : Illegal NSOutlineView data source
  • Display a text word by word slowly in swift
  • Is it possible to add a UILabel or CATextLayer to a CGPath in Swift, similar to Photoshop's type to path feature?
  • Initializing struct value with function
  • How can I deselect all rows in an UITableView?
  • Swift - unwrapping a Double value with a Guard let statement
  • How to change a view in a nib file on change of drop down value which is in same nib file in a bundle project?
  • Return data from struct and enum
  • Swift & Vapor/Fluent : How to pull values from another table during a post router request
  • URLSession.shared.dataTaskPublisher not working on IOS 13.3
  • How to retrieve value from Dict
  • In swiftui, How do I increase the height of a button?
  • Segue to another storyboard without using Storyboard Reference?
  • How do you use .enumerated() with ForEach in SwiftUI?
  • Handle internet connection automatically when internet goes off and comes again in swift 4
  • How to get difference (hour minutest second ) time from between two date in swift 5
  • How do I toggle fullscreen mode in SwiftUI?
  • How to animate a transform in RealityKit
  • How to extract Hashtags from text using SwiftUI?
  • Swift split strings efficiently
  • Displaying non repeating elements of array in Swift
  • How to update a macOS bundle without breaking notarization?
  • Pass in argument predefined or custom function in swift
  • SwiftUI call function on variable change
  • Trying to Update AttributedText for UIButton
  • Optional Error: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
  • How to get a Lux value from "ambientIntensity" expressed in Lumens?
  • Sharing ViewModel between SwiftUI components
  • swift vapor routes error - Type has no member 'save'
  • Does anyone know how can I validate digits from my currency input?
  • Swift: How to find a replace a a group of characters in a string, starting from a predefined character and ending with a
  • How to dismiss multiple view with SwiftUI
  • MTKView always render the background color to red
  • Deleting files from Documents Directory
  • Swift - Why can't self be used in a closure before all stored properties are initialized?
  • How to detect iOS device appearance update in a variable?
  • Bug when uploading app to real Apple Watch
  • Response token type in swift
  • Is it possible to have either or whereFields for Firestore query?
  • Generic parameter 'T' could not be inferred when XCTAssertEqual() called
  • How to convert String to JSON in Swift
  • TextField: Generic parameter 'Subject' could not be inferred
  • Is it correct to expect internal updates of a SwiftUI DynamicProperty property wrapper to trigger a view update?
  • how to detect when app is installed and start first?
  • NSFetchRequest predicate to sort by Date, using time component only
  • 'weak' may only be applied to class and class-bound protocol types, not 'ContentView' what im missing?
  • Swift Combine - Wait for all publishers
  • Basic Autolayout issue, resizing button after setting constraints
  • Swift Disadvantages Array of Any
  • Two almost identical targets in Vapor Xcode project
  • How to center button inside VStack Swift UI
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk