logo
down
shadow

Swift 4 delegate is not working with tabbar controller


Swift 4 delegate is not working with tabbar controller

By : user3100081
Date : January 12 2021, 01:40 AM
like below fixes the issue In MainVC's viewDidLoad you are creating a new SettingsVC instance and assigning self to that instance's property. Not to the actual forth view controller of the tab bar controller.
Get the fourth view controller instance from the tabBarController?.viewControllers array and assign self to its delegate property
code :
override func viewDidLoad() {
  super.viewDidLoad()
  if let settingVC = self.tabBarController?.viewControllers?.first(where: { $0 is SettingsVC }) as? SettingsVC {
    settingVC.delegate = self
  }
}
if let settingsNavVC = self.tabBarController?.viewControllers?.first(where: { $0 is UINavigationController }) as? UINavigationController, 
    let settingsVC = settingsNavVC.rootViewController as? SettingsVC {
        settingsVC.delegate = self
}


Share : facebook icon twitter icon
Tabbar controller accessing active navigation controller of current tab through app delegate

Tabbar controller accessing active navigation controller of current tab through app delegate


By : Kaito
Date : March 29 2020, 07:55 AM
wish helps you Figured out a viable solution for what I wanted to do. I created an outlet for the navigationcontroller I was trying to access and then just pushed my view
Can i take tabbar controller in view controller rather than delegate class?

Can i take tabbar controller in view controller rather than delegate class?


By : jumping4JESUS
Date : March 29 2020, 07:55 AM
should help you out Yes you can. See this link to an example
In your second view controller where you want to push to you third view(tab controller) do this
code :
UITabBarController *tabBarController=[[UITabBarController alloc]init];
tabBarController.viewControllers=[NSArray arrayWithObjects:firstViewController,secondViewController,thirdViewController, nil];
//[self.navigationController pushViewController:tabBarController animated:YES];// this works too but since it seems to be against Apple's Human interface Guidelines you can present the view instead of pushing
[self presentModalViewController:tabBarController animated:NO];
Present view from app delegate with a tabbar Controller-> Nav controller -> View Hierarchy - iOS Swift

Present view from app delegate with a tabbar Controller-> Nav controller -> View Hierarchy - iOS Swift


By : Satz
Date : March 29 2020, 07:55 AM
I hope this helps you . I'm not able to fully test this at the moment, but I believe that in a tab bar, you dont present the view controller. you set its view controller items and selectedViewController properties.
This should work, I'll test it and update shortly,
code :
var storyBoard = UIStoryboard()
        if UIDevice.current.userInterfaceIdiom == .pad {
            storyBoard = UIStoryboard(name: "iPad", bundle: nil)
        } else {
            storyBoard = UIStoryboard(name: "Main", bundle: nil)
        }


        let tabVc = self.window?.rootViewController as! UITabBarController

        let mynVC = storyBoard.instantiateViewController(withIdentifier: "nav") as! UINavigationController

        let calcVc = storyBoard.instantiateViewController(withIdentifier: "destVc")

        tabVc.viewControllers = [mynVC]
        tabVc.selectedViewController = mynVC
pass data from tabbar controller to view controller in swift and xcode

pass data from tabbar controller to view controller in swift and xcode


By : user1687867
Date : March 29 2020, 07:55 AM
I hope this helps . Take a look at the documentation for the tab bar controller, in particular the viewControllers property.
That property is an array of UIViewControllers, in the order they appear in the tab bar, so you can pick the one you need (viewControllers[0] from your screen shot), cast it to your specific view controller subclass and then pass it your data.
How to set rootview in tabbar controller and show tabbar in each view controller in swift ios?

How to set rootview in tabbar controller and show tabbar in each view controller in swift ios?


By : Bultador
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further This will help you. Try to set navigation inside of tab bar controller. Give tab bar item to navigation controller. Like:
Related Posts Related Posts :
  • How to connect an iPhone app (rest) to XAMPP using a local WIFI connection?
  • How do i compile all contact's phone numbers into one cell - using CNContact
  • How do I change the color of two UIButtons when I press them?
  • UIViewPropertyAnimator doesn’t work as expected
  • GoogleMaps camera target in top left corner of map iOS since pod update
  • Allowing SwiftUI to import all Contacts and delete specific ones
  • How can I obtain POST request body from WKWebView in Swift?
  • Why is array in collection view getting multiplied by amount of sections?
  • How is enumerated() constant time O(1)?
  • How to get XML data and bind in tableview in iOS Swift?
  • Interface Builder Constraints Problems
  • Xcode 11 beta can't upload app to TestFlight
  • iOS odd Thread 1: Fatal error: Index out of range on iPad
  • Cannot convert json object to struct
  • How can I prevent the stopwatch from resetting after pause
  • Cannot convert value of type '() -> _' to specified type '[UIViewController]'
  • How to make a reference to a uid stored in Firestore?
  • How do you initialize/use UITableViewCells with CellStyle = .value1 programmatically?
  • How to know if Apple has received our appeal/how long does it take Apple to respond?
  • Select new item added to SwiftUI List
  • What is the correct length: argument to provide to NSRange for NSRegularExpression using a (Swift) String?
  • I am trying to delete data from database, but sometime data is deleted and sometime data is not deleted
  • How to get slider value with subview rotation angle
  • Can't pass custom UINavigationBar / UIToolbar to UINavigationController because they don't conform to AnyClass
  • Remove app before simulator or device is lunched from Xcode
  • Auto Layout constraints for container view inside UITableView header broken for different devices
  • iPhone restarts after API call
  • What is the shortcut / How do I create function after writing it's usage in Xcode
  • Convert apple time stamp to Unix time
  • No podspec found for `React-fishhook`
  • How to test touch dialog and perform real in-app purchase?
  • Compiling Metal shaders from source on iOS 13 Simulator gives PCH error
  • conan error:I need to cross build packages for os:iOS with my Macos, but when the first package was done, it broke my cp
  • Update calendar 'start of week' from phones system calendar
  • Xcode is showing some warnings
  • How to remove the default Navigation Bar space in SwiftUI NavigiationView
  • Having trouble integrating multiple pickerviews in the same view
  • SCNNode not in SCNView hierarchy, still showing & getting touches & physics
  • How can I open my SwiftUI app and perform a function using NSUseractivity from within Siri Intent Extension?
  • NSCoding decodeObject always nil
  • Passing data in a segmented Controller?
  • Facing issue in Siri Integration with custom intents
  • ARKit3 Hardware Requirement Clarification
  • ARKit3 How to use TrueDepth camera for face tracking and face meshes of other people?
  • How to discriminate while decoding using Codable Protocol in Swift?
  • 'IPA processing failed' while distributing build in Xcode Beta
  • How to debug a crash which happened when come back from background
  • Synchronising old data with NSPersistentCloudKitContainer
  • iOS app opened from web app with url redirects to Appstore
  • How to change the color of seperator in tableView?
  • Is there a better way to watch for a key-value change?
  • How to make UIBezierPath to fill from the center
  • Why on Xcode 11, UICollectionViewCell changes size as soon as you scroll (I already set size in sizeForItem AtIndexPath:
  • How to scan non LE devices using Swift?
  • Unable to infer closure type in the current context in SwiftUI
  • What is the best way to write common code and use it entire project
  • UISegmentedControl inside UIStackView, segments text not centered - iOS 13
  • Swift & ObjC bridge - cannot find protocol declaration for "WKNavigationDelegate"
  • SwiftUI How to push to next screen when tapping on Button
  • 'NSApp' is unavailable in UIKit for Mac: How to embed Mac only framework in iOS app on macOS?
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org