How to go to tabbar item from an external view controller - ios

Im stuck with a problem me and a friend of mine are building a app in ios. see video.
please watch this video:
https://youtu.be/SHrBF6h8Nso
The problem is when we are done with the workout and we get to the finish workout screen and we click on the profile button it goes to the workoutOverview Screen. But we want it to go to the profileOverview screen.
We try to achieve this with this line of code :
self.tabBarController?.selectedIndex = 1. // this results in segue to workoutOverview instead of profileOverview, no matter what index we use
But finish workoutOverview is not part of tabbar controller or the navigation controller that we have.
the second problem
When pressing the cancel button (cross) we would like to pop to the first viewcontroller (muscleList) but without losing the tabbar!
see how our storyboard is connected in the picture:
Question:
How to go back to profile view controller in the tabbar controller?
How to show view controller with tabbar controller when click on the cancel button?
If anyone have a idea it would help us a lot.

xCode has a bug with the show segues. Change all "Show" segues to the deprecated "Push" segues and build and compile. Than change all back to "Show" again, build, compile and it works now! All viewcontrollers will be added to the stack.

Related

Xcode black bar on top of view controller after connecting segue

I have a problem with my Xcode project. The problem is that when I link one of my view controllers up to another with a segue a weird black bar appears on the top. Here's a video of that problem.
https://imgur.com/a/ctttXlZ
Does anyone know what might be causing this?
This is because the segue to the second ViewController is a "show", and the second VC will show like this:
If you want this VC to be full screen, click on the segue you created, change the "Kind" property to "Present Modally", and the "Presenttion" property to "Full Screen":

Swift NavigationControllerBar Back Button

I am new in iOS development and in Swift. I have a question. I added in one of the ViewController NavigationController. But I have some problems with back button cause it doesn't appear on other Views. I tried with self.pushViewController() and with self.present() but it doesn't work. If I mark in NavigationController Is Initial View Controller then everything is fine but I don't want it because then app starts with this screen(where I have NavigationController).
Please help me, what I should to add or to write?
This is an image of my storyboard
And this is what I have if I run and go to another ViewController, as you can see I don't have navigation bar and back button.
You got 2 options :
1) Add a navigation controller in the root ViewController, Hide throughout except the last one. Make sure you push the last VC so Back option will be there by default
self.navigationController.pushToViewController(BarCodeViewController)
2) Use a custom View on top of last viewController add a custom button to that view. But this time present it from previous ViewController
self.present(BarCodeViewController)
when back button clicked dismiss it by adding target to the button. self.dismiss()

Segue to navigation controller goes black

I am trying to create a segue from a button to a navigation controller that a master view controller is embedded in (I used the "Your Second iOS App" tutorial by Apple Developer). The problem was that whenever I clicked the button, I would get a totally black screen with just a navigation bar. There isn't any code involved. Would anyone happen to know how I could fix this? Any help would be appreciated. Thanks
Actually, I figured it out. It was because the split view controller was also pointing to the master view controller, so it had 2 segues pointing to it.

JSQMessagesViewController back button not visible

I follow this basic tutorial to start playing with JSQMessagesViewController:
https://www.raywenderlich.com/122148/firebase-tutorial-real-time-chat
How can I do to have a back button in the ChatViewController?
When debugging it seems to be here but maybe masked by something.
Thank you for any feedback.
Regards
Your problem is that the "ChitChat" scene is the root ViewController; there's nothing to go back to!
Even though the Log-In screen appears before the ChiChat VC, you can see how it segues TO the Navigation Controller, which is Embedded in the ChitChat VC.
Think of it like this:
Since the Log-In VC appears before the Navigation Controller, it never sees it, and doesn't know that there's a screen to go back to (this is simplified logic).
If you want to have a back button to go back to the Log-In VC, then try playing around with embedding the Navigation Controller in the Log-In VC (By using the editor tab, and then selecting "Embed in" in xCode, if you've never done this before)

Xcode / Swift: How I implement a back button?

I just started with Xcode and Swift.
I try to build my first little App for iOS. But now I have the problem, that I don't know how to implement a the back button, so that i come back to the view before.
My Storyboard look like this:
When I open the A-Z view, I want to display the Back Arrow, which turn me back to the Item 2 view.
To open the A - Z view I connect the button "Medikamente A - Z" with the Navigation Controller.
When using storyboards the back button is usually implemented with unwind segue.
I usually like to follow raywenderlich toturials on UI related topics, like this - http://www.raywenderlich.com/113394/storyboards-tutorial-in-ios-9-part-2
It include a detailed example of how to implement back button in storyboards. Quoting from it -
Storyboards provide the ability to ‘go back’ with something called an unwind segue, which you’ll implement next.
There are three main steps:
1. Create an object for the user to select, usually a button.
2. Create an unwind method in the controller that you want to return to.
3. Hook up the method and the object in the storyboard.
When using UINavigationController, whenever you push to a new ViewController the back button will automatically appear, so you can jump back to the previous View Controller.
So it's works like:
UIViewController -> UIViewController -> UIViewController
A back button will appear on the last 2 so you can pop back the the previous ViewController.
You don't have to do any additional coding for the back button to appear, it'll do it on its own. I hope this clears it up. Let me know if you have any questions.
To implement a back button, your root view controller has to be a Navigation Controller.
The first view controller becomes the navigation root of the navigation controller.
If you want to present another view controller, you select a "Show Detail" relationship as the action for the button which should show the view controller. To do this, Ctrl-click and drag from the button to the destination view controller and select "Show Detail".
I had the same problem, even when on the storyboard the back button was visible at design time.
I deleted the segue, and recreated it with "Show" instead of "Show detail". Changing the segue to "Show" had no effect. I think this is a bug, so if you miss that back button delete and recreate the segue.

Resources