I am developing an App that has the following set up:
There is a login screen; if the login is successful, then the tab bar view is opened. All views are created in main.storyboard. The opening is handled as follows:
instantiateViewControllerWithIdentifier("personalViewController") as! PersonalViewController
self.presentViewController(vc, animated: true, completion: nil)
It does open my new view controller, but the bar items are not visible. Anyone knows how to fix this?
Thanks!
You have to open the TabBarViewController instead of the viewcontroller that is inside of the tabbar viewcontroller.
I recommend just looking at the documentation in XCode. All documentation is written in Swift and Objective C so it is very easy to translate between the two languages. Also read apple's swift basics to understand this code translation better: https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-XID_467
presentViewController is going to open the personalViewController as a modal view. If you want to push the view onto the navigation controller stack (i.e. open it like a new screen) then you could/should use:
self.navigationController?.pushViewController(viewController: UIViewController, animated: Bool)
Related
Pretty simple problem - now that I'm using Swift 4.2, my segues are "stacking" the view controllers physically. When I segue, the new view controller is not brought to the top of the screen and can be dragged down to go to the view controller before it. When I segue, I want the previous view controller to be entirely covered by the new one. How do I achieve this? Am I forced to use a navigation controller now?
What you are seeing is a change in the default modal presentation style for iOS 13. There are different possible ways to address it depending on your intent. These question and answers cover those possibilities:
Presenting modal in iOS 13 fullscreen
change the presentation style
for example
let VC1 = self.storyboard!.instantiateViewController(withIdentifier: "sideMenu")
VC1.modalPresentationStyle = .fullScreen
self[![enter image description here][1]][1].present(VC1, animated: true, completion: nil)
or if you are using storyboard, check the segue properties
I've had this issue for months with multiple views, both Apple provided like ImagePicker and VCs from storyboard.
I believe that it has something to do with the underlying views we have both a tab bar controller and navigation controller in most views.
Strange thing is using some open source views from pods does not cause this bug.
So I'm two views deep on a navigation controller and present another view modally on top with present(vc, animated: true, completion: {})
Works like a charm, now dismissing that view with dismiss(animated: true, completion: nil) throws me back all the way to the initial view or root view of the navigation controller, had both happen before, depending on the presented view.
Update:
Build a sample project trying to reproduce the behavior but failed. Drew a reduced diagram to better explain the current bug behavior.
Also noticed that if I'm invoking the post view one step earlier in the Fandom view it works as expected.
In my case i am using UITabBarController, and I wrote code in viewWillAppear of UITabBarController
self.selectedIndex = 2
so when i present any thing from any controller whose parent is UITabBarController and when i dismiss that it automatically open third tab of UITabBarController.
Maybe you explicitly wrote any code to select specific index of TabBar.
Maybe this is useful for you or anyone else.
I'm pretty new to swift development but I am trying to implement a back button in my application.
I have the following layout in my Main.storyboard
As seen in the picture the navigation bars display however when i lunch my app they are not visible.
I also have tried using a button that will take me back to the previous view with
self.navigationController?.popViewControllerAnimated(true)
but it has not worked
Update:
The image above doesnt show the initial controller which is my ViewController
the problem is that All Routes is actually a PageContentViewController which is called from ViewController which checks for fb login than calls:
dispatch_async(dispatch_get_main_queue()){
self.setViewControllers([self.getViewControllerAtIndex(0)] as [UIViewController], direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil)
}
So i cannot change my initial view controller.
I dont know how I can get around this problem.
Is there a way to do it from Main.storyboard or a programistic solution ?
Embedding my initial view in a navigational controller and setting it to the initial view has worked.
Even though it doesnt look right on the preview because my initial view calls the other views programmatically it works correctly on the device
Hey I am building my first ios application using xcode. I'm a total noob in xcode and swift and I am trying to use the storyboards to set-up my app. Here's a link to the prototype http://adobe.ly/1q5Imf6.
Basically my issue is where I want to do the split view on the resellers page. I want to use the splitviewcontroller only on the page, so after an intro viewcontroller in a navigation controller. like this
I read somewhere that a splitviewcontroller must be the initial view controller, however this works if I use segues that pop up modally. But when I do that I don't really have a navigation bar anymore on the page. I only have the splitview, but there must be the option to go back.
Am I doing this completely wrong or is there a simple fix to get what I want?
If you want to present your UISplitViewController modally, then you need to wrap into UINavigationController. After it you can add UIBarButtonItem in your UISplitViewController and set an action to dismissViewControllerAnimated(true, completion: nil)
I have an application that links to a view via a button (which is embedded inside a navigation controller)
Which all works fine! I hit the button and the view is presented using Segue Show Eg: Push. The view pops over and I see a UINavigationBar with my title and a button to dismiss.
My question is.. I need to programatically call this view again in my code, however, when I do this the view appears without any UINavigation. I assume it does this because it's no no longer embedded inside the UINavigationController?
Whats the best solution for this? Should I programatically create the UINavigationBarController? If so how would this look in swift?
Thank in advanced.
// Code below is triggered from an action (button) on UIAlertController.
// This loads up the "Scan Barcode view" without the UINavigationBar embedded.
let scannerViewController = self.storyboard?.instantiateViewControllerWithIdentifier("ScannerViewController") as ScannerViewController
self.presentViewController(scannerViewController, animated: true, completion: nil)
When I set up the connection using interface builder from another button (located elsewhere) so show the same view. It works perfectly showing the "Scan Barcode" embedded inside the Navigation Controller.
When using interface builder to link (from the camera button) it works perfect.
Thanks to #kpsharp the solution was just to use
self.navigationController?.pushViewController(scannerViewController, animated: true)