logo
down
shadow

How to change RootViewController programmatically?


How to change RootViewController programmatically?

By : Hasan Bardakçı
Date : November 14 2020, 04:48 PM
will help you I am developing some custom camera app, I just want to skip my login page and make my camera home page to initial root view when user already registered. I'm doing it from AppDelegate or inside the view code however I'm getting an error any one described it from scratch or any sample example. My code is below,
code :
-(void)viewWillAppear:(BOOL)animated{
    // check if user is already Logged in
    if([defaults objectForKey:@"username"]!=nil  && ![[defaults objectForKey:@"username"] isEqualToString:@""]){

        UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
        UIViewController *view = [storyboard instantiateViewControllerWithIdentifier:@"HomeScreen"];

        [self presentViewController:view animated:YES completion:nil];
    }
}


Share : facebook icon twitter icon
Going to the rootViewController of another navigationController programmatically?

Going to the rootViewController of another navigationController programmatically?


By : NBStudios
Date : March 29 2020, 07:55 AM
This might help you I have an iPhone app with a UITabBar, and each tab has a unique navigationController. , you can pop to root view controller as
code :
[(UINavigationController *)self.tabBarController.selectedViewController popToRootViewControllerAnimated:YES];
Programmatically change rootViewController of storyBoard

Programmatically change rootViewController of storyBoard


By : Leonie Schonewille
Date : March 29 2020, 07:55 AM
I hope this helps you . I have created my project using Storyboards. The root ViewController lies inside a Storyboard, I have not written a single code in the appDelegate. , Objective-C:
code :
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UITabBarController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"tabBarcontroller"];
[[UIApplication sharedApplication].keyWindow setRootViewController:rootViewController];
 let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
 let viewController = mainStoryboard.instantiateViewControllerWithIdentifier("tabBarcontroller") as UITabBarController  
   UIApplication.sharedApplication().keyWindow?.rootViewController = viewController;
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewController(withIdentifier: "tabBarcontroller") as! UITabBarController
UIApplication.shared.keyWindow?.rootViewController = viewController
Create a TabBar programmatically but not on the rootViewController

Create a TabBar programmatically but not on the rootViewController


By : Dhruva Upamanyu
Date : March 29 2020, 07:55 AM
I hope this helps you . Push to UITabBarController instead of CreateElement tableViewController, when didSelect of tableview called in Element TableViewController.
From didSelectRowAt indexPath of Element TableViewController
code :
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let tab = TabbarController()
    self.navigationController?.pushViewController(tab, animated: true)
}
class TabbarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let createElement = CreateElementTVC()      //Create Element TableViewController
        createElement.tabBarItem = UITabBarItem(tabBarSystemItem: .history, tag: 0)

        let more = MoreVC()                         //For eg. take empty UIViewController for another tab
        more.tabBarItem = UITabBarItem(tabBarSystemItem: .more, tag: 1)

        //Assign view controllers which you want to show in tab bar
        self.viewControllers = [createElement, more]. 
    }
}
How to programmatically come to rootViewController without using UINavigationController

How to programmatically come to rootViewController without using UINavigationController


By : user3055271
Date : December 21 2020, 03:04 PM
Hope this helps I'm using swift in iOS. I have to navigate back to my rootViewController from the current UIViewController by clicking on a button and I am not using UINavigationController. , Try this in your button action:
code :
@IBAction func buttonClicked(_ sender: UIButton) {
    self.dismiss(animated: true, completion: nil)
}
how can i change programmatically the rootViewController using Storyboards?

how can i change programmatically the rootViewController using Storyboards?


By : Burt Walker
Date : March 29 2020, 07:55 AM
Any of those help You can set a cookie (using NSUserDefaults for example) telling you that you need to start from a different view controller. Then in you app delegate you can check for this cookie value and change the initial view controller of your storyboard like that
Related Posts Related Posts :
  • Unclear about releasing CFDictionaryRef
  • CordovaError: Promise rejected with non-error: Error code 65
  • How to append NSMutable strings into a UILabel
  • CustomCell label value does not change
  • Display ad in iAd Bannerview iAd Network
  • Warning: "Could not get traitsetID for iPhone11,6" (Assets.xcassets)
  • Changing root view controller after iOS app has loaded.
  • SocketRocket and iOS certificate pinning
  • Draggable UIButton Snap To a Circle Path
  • Running FireBase in the background
  • resizing UIPopoverController to fit UITableController
  • UICollectionView Exception Crash
  • targeting iOS5 - will it work on iOS6 also?
  • FBLoginView get email
  • Scale UIImages height to UIImageView height
  • Creating a custom progress indicator in ios
  • NSRunLoop API difference
  • Is it possible to inject custom settings into my iOS application "Notifications" settings dialog?
  • UIAlertview not accepting string as message
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org