How can I change the Storyboard animation for modal in Xcode 4.2? - ios

I am quite new to Xcode coding and I have been using Storyboard for along time, if you know when you link a button to a view and select the option "Modal" it will make a link with the animation of the new view coming up from the bottom. I was wondering if it was possible to change the animation to the new view coming from the right. I am sorry this question was so brief, if you need more info just ask me.
Thanks.

If you select the segue and look at the Attributes Inspector (on the right side of the window), you will see a pop-up menu labeled Transition. This menu lists the available transition styles for the segue:
Cover Vertical
Flip Horizontal
Cross Dissolve
Partial Curl
If you want a different style of transition, you will need to use a different type of segue. If you have a UINavigationController hosting your source view controller (the one that contains the button), you can use a Push segue, which slides the new view in from the right. If you don't have a navigation controller or don't like the Push segue animation, you'll have to implement a custom segue to change the animation.

More on custom segues
Custom Segue- Apple
Custom Segue + CATransition
-anoop

Related

Why does View Controller Shift in Storyboard on Button Segue

I am new to IOS App development and have a question. I'm trying to segue from one view controller to another. However, it seems that every time I ctrl+drag from the options button to the adjacent view controller and choose the 'show' option, the view controller "shifts" down(bottom picture). Why does that happen and if it is not the correct behavior, how can I do it right? Thanks!
You need to set fullscreen style manually if select model style,
a fullscreen option did not show in Push type, you must use Navigation Controller if you want to set fullscreen for Push
https://i.stack.imgur.com/rg20Y.png
When you click on the segue(the line that connects view controllers) and open the Attribute Inspector in right panel, you will see the Kind is set to Present Modally. This means your view controller will popup on your current screen.
You can change the Kind to Push and it will start showing normally.
Also embed your controller in a navigation Controller
Option 2
If you dont want a navigation controller, you can also change the presentation to full screen.
If you're new to iOS
then I might suggest don't use show and don't use segue from storyboard
If you don't know the concept of navigation controller (push and pop methods), then have a look at it (You may not use show afterwards)
have a look at following link
Swift programmatically navigate to another view controller/scene

XCode 7 Storyboard segue usage confusion

I'm trying to make segue using storyboard, and I found it's really confusing for me. Sometimes, when I drag and drop segue push or modal, both will act like modal (bottom to up). And sometimes, it will act like push (right to left). I'm also using navigation controller to handle the right and left button. Do you know why it happens? How do we make sure that if we want to View Controller to animate right and left, we use push. and if we want to use modal, the View Controller to animate bottom to top. Thank you guys!
Check you are using the correct type of segue -->
On the right hand side, after selecting the segue -->

Proper way to segue between two simple View Controllers in iOS 7

I'm mainly from a C# background, so the workflow for iOS is a bit unusual for me, at least for now.
I was having a problem having simple segue from a main menu, to a another menu/work area, and then with the ability to go back to the main menu.
For a test, apparently I did something wrong.
I didn't write any code for this test to exhibit the problem.
What I did was just,
create a new single-view app
drag an additional view controller onto the work area
drag the start arrow to the new view controller (so it becomes the initial view, same thing as checking the checkbox to set it as the initial view)
added a button to each view controller
Ctrl + clicked and dragged the buttons to the opposing view
for the segue type, I chose "replace"
now the program crashes if I hit the second button to go back to the "main menu" (green view controller in this example)
So what am I doing wrong? Do I need to add some form of delegate or something?
I did find this, though it present fewer segue options in the tutorial than what I have.
https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/SecondTutorial.html
These are the options I have when I Ctrl + Click from a button to another view
-Push
-Modal
-PopOver
-Custom
-Replace
"Have you embedded a navigation controller? You need to go to editor->embed in-> Navigation Controller. You need a navigation controller for push segue. – Kaushal Bisht"
This solved it for me. Now I'm just going to work on replacing the navigation bar with custom UI controls.
Thanks everyone! :)

iOS: How to get a modal view to partially cover the parent view?

I am quite new in iOS development and I am facing an issue with the design of navigation. So my goal is simple: I have a view with a right navigation button which I want to open a modal view that would partially cover the parent view like on this screenshot: modal view example
Currently this is what I did: I embedded a UIViewController in a UINavigationController, then I added a right navigation button in my view controller which navigates to another UIViewController through a modal action segue. But whenever I navigate to the modal view, it fully covers the parent view.
So how can I get it to only cover partially the parent view with Interface Builder settings? Or do I need to use some code behind to achieve that?
Thanks for your help :)
NB: I don't want to use Popovers, I want it to be in the middle of the screen with no attach.
To achieve this you have to select your segue and modify the Presentation property to Form Sheet, as shown in the image below

Swap/ Transitioning between views iOS programming

I am a newbie to IOS programming and currently i have a tab bar application with two tabs. I have two questions.
The first tab shows a map, imagine it with some pushpins. There is a button on the navigation bar and when this is clicked i want the map view to to move out and a list view to come in. You can see the UI from the image. The button is called list.
Now when i click list I want this view to go away and the list view to come in. So here are my questions ?
1) How do i do this ? I tried the navigation model but i don't want that because I do not want a back button. I tried to make two different views and just dragged the button to that view but the app crashes. I just want the list button on the nab bar and when clicked the view changes to the list view and the button text changes to map. So now if I click the button again it should go back to the map view and the button changes to list.
2) How do i achieve the animations for this ? Ive seen some app where the page flips around and I've seen some options like reducing the opacity etc but I want to achieve the flip animation.
Thank You for any help I get. I really appreciate it.
Interface Builder can do most of this. Hold down the control key and drag from your map View Controller's UIBarButtonItem titled "List" to your list View Controller, then choose the Action Segue "modal". An arrow appears representing the segue; click on it and use the Attributes Inspector to change the Transition to "Flip Horizontal". Here's a video
Or, you could do this programmatically with presentViewController:animated:completion.
Now to get back to the map from the list, I believe that must be done programatically. Create a method that calls dismissViewControllerAnimated:completion: and make your list View Controller's UIBarButtonItem titled "Map" trigger it.
After reading your comments, I am wondering... if the structure of your app is logically a tabbed app structure (as indeed you refer to it as a 'tab bar application'), shouldn't you consider using the UITabViewController instead of a NavigationController? That is what it is designed to do, after all.
If you do use a TabViewController you should reconsider your desire for flip animation, as that doesn't really make UI-sense for tabs. If you can dispense with the flip animation, TabViewController could be a good way to go and you should at least experiment with that before dismissing the idea. It is also designed to grow... you can incorporate any number of tabs in a tab bar. Check out the apple docs (with pictures!)
You will notice that tabs are at the foot of the screen, whereas your 'tab' navController buttons are in a navbar at the top of the screen. This also helps as your app grows, as it is straightforward - from a UI design point of view and programmatically - to incorporate navControllers as navigation tools within individual tabs. For example, if your map/list flip routine does indeed make sense for this part of you app, you can keep this as a single tab (in it's own navigationController) and add other tabs for other parts of the app...
update
From your comment, you are saying that you are interested in the navController-inside-tabBarController setup. In this case here are some ways to get flip transitions AND no back button..
(1) modal presentation
The easiest way to get what you want is to set up one of your viewControllers (say the map view) to present the other one (the list view) modally.
If in the storyboard:
embed your mapViewController in a navController with a navbar button for navigation to the listView as in your picture
add your listViewController to the storyboard and embed it in it's own navContoller (not the mapViewController's navController). Drag a barButtonItem to this navController and wire it up to an IBAction in listViewController
CTRL-drag from mapViewController's 'list' button to the listViewController to create a segue. Select the segue and in the attributes inspector set the segue type to 'modal', with transition 'flips horizontal' and 'animated' checked. Give it a name in case you want to refer to it in code.
in the listViewController's IBAction add this:
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
That should achieve your result. You can use the completion block to send information back from the list view to the map view, and/or set the map view as the listView's delegate.
If you are not using the storyboard check this apple guide
Presenting View Controllers from Other View Controllers
especially "Presenting a View Controller and Choosing a Transition Style".
There is one catch with this approach - when the presented view flips onto the screen, the entire previous view, including the tab bar, is flipped out of the way. The idea is that this is a modal view which the user is required to dismiss before doing anything else in the app.
(2) push/pop in a single navController If this does not suit your intent, you can navigate using a single NavigationController with push and popping of views, and you can hide the back button ... but you really would need to keep the back button functionality as you do want to go back to the mapView, not on to a new map view.
To hide the back button try:
self.navigationItem.hidesBackButton = YES
in the uppermost viewControllers' viewDidLoad
Then you can add a barButtonItem in the xib/storyboard, with this kind of IBAction:
[self popViewControllerAnimated:NO]
or
[self popToRootViewControllerAnimated:NO]
You would have to construct the flip animation in code as it is not supported as a built-in with UINavigationController (best left as an exercise for the reader!)
(3) swapping views in a single viewController As ghettopia has suggested, you could use a single viewController inside a navController (or with a manually place navBar) and swap two views around using the UIView class methods
transitionFromView:toView:duration:options:animations:completion
transitionWithView:duration:options:animations:completion.
This could be a good simplifying solution as your list and map are essentially two views of the same data model.

Resources