Multiple Segue from single UIButton which is changing due to ImageView - ios

In main view controller there is an ImageView in the middle, UIButton in the bottom. The ImageView has tap gesture and when you tap it the image changes from Credits to Scenes images and the Button title changes to Credits Button from Scenes Button. Those buttons must have segues to its own. So I want to create segues to CreditsController and ScenesController from that button. I couldn't create double segue from the storyboard.
I appreciate for any help and I can provide more information if necessary.
Thanks.

You can do "double segues" from a storyboard. There are two methods:
Ctrl-drag from the view controller symbol (the yellow one) to the destination view controller. Name the segue and call it (in the button handler or the gesture recognizer handler) with performSegueWithIdentifier.
Use separate buttons with title or image and set their hidden property as appropriate. Now you can ctrl-drag from the buttons to the destination view controller.

Related

Inside a UITabBarController how do I segue from one view controller to another and retain the tab bar?

I drag a UITabBarController from Object library to the storyboard.
From firstViewController I want to swipe to another viewController named CustomController using a swipe gesture recognizer and retain the tab bar on CustomController when it is instantiated.
The problem is that once the segue is performed from firstViewController to CustomController, the tab bar no longer shows at the bottom of Custom Controller and it does not swipe back to firstViewController.
This is the outcome I would like to achieve. Please advise best route.
You can use ContainerView to view your view controller. when you
click on segment 1 you can set your firstviewcontroller to
containerview and when you click on segment 2 you need to replace customviewcontroller in containerview. you do like this you will not lose your tab bar viewcontroller. For Swipe gesture, you
can add it later if you want. Hope this can help you.

Navigation Item not visible in interface builder after adding segue

I have custom UIView, that uses .xib file. I'm adding this view in storyboard inside view controller. After that I added TapGestureRecognizer to it. Then I attach segue to tap gesture recognizer (no code needed to perform segue from custom view this way).
Problem is, navigation Item is not shown in interface builder. When I build and run app, navigation is on screen and everything works like expected.
When I add segue from VC to VC, navigation bar is shown in interface builder. Why I'm getting such behavior?
That seems like a bug in Interface Builder to me.
I see two possible workarounds for this situation:
Wire the segue from ViewController to ViewController. Give it an identifier. Call it programmatically with performSegue(withIdentifier:sender:) in an #IBAction for your Tap Gesture Recognizer. The downside of this is that you need to add code.
Add the Navigation Bar to your ViewController by setting Attributes Inspector -> Simulated Metrics -> Top Bar to Translucent Navigation Bar. This allows you to see the Navigation Bar in Interface Builder. The downside of this is that you need to do this for every ViewController down the chain.

How to transition to a view controller with gesture swift iOS

I have a problem with implementing a button which should redirect my current view to another view when tapping on it.
I have a central view and I already implement the gestures on top, left and right to move to others views.
But on this central view I want to add a button that allows me to redirect towards my right screen without using gesture from right to left with my finger.
I added an IBOutlet action for this button, but I do not know what method to implement for switching back to my right screen (not the top or left screen).
If anyone can help me thank you very much!
If you create a segue in Interface Builder and give it an identifier. You can then perform this segue (what you call "a transition") by calling
performSegue(withIdentifier: <String>, sender: self)
Of course you will need to replace <String> with your segue's identifier
One can create a segue by control dragging from one view controller to another view controller
One can give a segue an identifier by
clicking on the just created segue (this is a line between the view cotrollers in the storyboard)
opening the Attributes Inspector (press: altcmd4 or click on: View > Utilities > Show Attributes Inspector)
filling in the textfield next to the label "Identifier"

Storyboard loses navigation bar when segueing via tap gesture

My app has two scenes: a UIViewController with a navigation bar at the top, and a UITableViewController. If I wire up a button in the first scene to segue to the table view, everything looks great. However, if I wire up a tap gesture in the first scene to segue to the table view, then the navigation bar doesn't display in the second scene in Xcode. When the app is run, the navigation bar appears as it should, but in the storyboard editor it is gone.
Is there something special that needs to be done to preserve the navigation bar when segueing from one scene to another using a tap gesture? To implement the tap gesture, I dragged it onto one of the elements in my storyboard, then control dragged from the "tap gesture recognizer" icon at the bottom of the scene to the scene I wanted it to segue to. Then selected "push" for the segue type.
I never noticed this before, but I do see the same thing. This seems like a bug to me, but maybe Apple has a reason for doing this. You can go to the "Simulated Metrics" for your controller, and set the "Top Bar" to be a navigation bar, which will allow you to set the title and add a bar button item if you want.

Can't create Segue from UIScrollView

I have a UIScrollView with my View, but I can't seem to create a seque push from this over to another controller.
I have successfully created a Seque from a UICollectionViewCell over to my destination controller but when I try and create one from the UIScrollView (in the StoryBoard) the blue connector will not see the destination controller as an option to create a segue too.
Any pointers would be much appreciated.
A push segue is only meant to be used with any type of button (ex. UIButton, UIBarButtonItem) or cell (UITableViewCell). Push segues are used to show another view controller over the current one. UIScrollView is only meant to scroll the content on the current view controller, just in case the content of the view controller exceed the screen size. I suggest you look at the Apple UIScrollView Class Reference page here to get a better understanding of UIScrollView
Push segues don't have to be connected from individual views like UIButtons or UITableViewCells. This is too limiting, because a button (for instance) can only connect to one segue. Try connecting them from the view controller itself, then you will be able to do as many as needed. I open the Document Outline, and drag from the View Controller at the top of the scene (the item having the yellow circle icon next to it) to the view controller on the Storyboard that I want to connect to.

Resources