I am trying to build a custom segue for an iOS app that utilizes images on the top and bottom of the screen (like a header and footer) that will slide up/down (out), transition to the next page, then slide back in. I found a simple tutorial that does the animation that I would like to use, but I am stuck trying to implement it into a segue.
Is this possible? If so, how? I have barely found any documentation on what I would like to do, and I am royally stuck!
Thanks in advance.
Animation tutorial: http://www.raywenderlich.com/2454/how-to-use-uiview-animation-tutorial
iOS 7
What you're asking about is possible with new APIs. However, iOS 7 is currently under NDA. Please avoid asking iOS 7 related questions on Stack Overflow until the SDK, Toolchain, and OS go final. Ask this question on the iOS Developer Forums. When iOS 7 becomes public, I'll edit this answer to describe how to do it.
Meanwhile (since you're a registered developer), I can point you to a few resources that may be of interest (you may need to sign in to access them).
WWDC Videos
The video titled Building User Interfaces for iOS 7 introduces the new Segue animations and techniques. The part of interest is around the 18:30 minute mark.
The video titled Custom Transitions using View Controllers goes in depth to explain the new custom animated segues and how to use them.
Creating Custom Segues - Pre-release documentation
Posts about Segue's on the Dev Forums - Just search the Developer Forums
iOS 5 - 6
Creating custom segues in earlier versions of iOS (5.0 and up) is fairly straightforward, unlike iOS 7 - the animations can't really interact with views within your ViewController and they aren't as dynamic.
To setup a custom segue, you'll need to first create a subclass of uistoryboardsegue (Documentation Here). Override the perform method and add your own animation and drawing code:
- (void)perform {
//Add your own animation code here, then present the View Controller using that custom animation
[[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
}
Now that you've subclassed UIStoryboardSegue and created your own animation, you'll need to connect the segue in Interface Builder.
Create the Segue by Control-Dragging from the source view controller to the destination view controller.
Select custom from the list
Name the Segue by setting its Identifier (this way you can also call the segue using the performSegueWithIdentifier:sender:) method. Then set the Segue Class to the name of your UIStoryboardSegue subclass.
Related
I would like to implement a layered viewcontroller control, where pushed viewcontroller doesn't cover the entire screen but will leave say 20pixela width on the left. If 5 viewcontrollers are pushed and I'm tapping on viewcontroller 2, it should expand, but not remove viewcontroller 3,4 and 5. Only slide them to the right.
The idea comes from the iPad app Trivago and I don't know if they're using an open framework. If not, do you guys have a good idea for implementation? The structure/architecture is fine :-)
If I can create a nice control I will make it public as a cocoapod :-)
Thanks!
Sounds like you may want to do View Controller Containment instead of using a UINavigationController.
See: Creating Custom Container View Controllers
Update:
More examples:
WWDC 2011: Implementing UIViewController Containment
iOS Programming Recipe 28: View Controller Containment & Transitioning
I am aware that Apple have previously stated that UISplitView controllers should not be used within a TabBarController by reading through other posts on stackoverflow - I had a look at the relevant documentation on this in the Apple developer site, but I couldn't find anything to suggest this shouldn't be done.
I know that in previous versions it was due to the fact that the SplitViewController did not properly receive the orientation messages - however my app is always in landscape mode.
I have 9 split view controllers - and if I had to change this now it would be a major re-design for my app - infact I am not too sure of another way of displaying the data in a format I require!
Does anyone have any experience of this situation being accepted by Apple in an app recently? I am just concerned as there are so many posts (from 2010 onwards) saying this must never be done, but when looking at the SDK documentation I can't see why not.
The UISplitViewController itself is not allowed to be included in navigation controller or tabbarcontroller. I used the MGSplitViewController, from MGSplitViewController, however I haven't submitted it to Apple Store yet.
MGSplitViewController is of class UIViewController so you get to include it in a tab bar.
I have a very very old iPhone/iPad app, actually it was my very first Objective-C app, I started learning iOS programming on it. Now I want to update it a bit but have following problem:
The app has never had any viewController. When I started writing it, I wasn't familiar with MCV and Interface Builder. First version was just for iPhone and it made the UI manually by just positioning UILabels and UIButtons in UIApplicationDelegate's didFinishLaunchingWithOptions via addSubview directly into self.window (there is MainWindow.xib but it's empty). A couple of months later I created iPad version. It has all the UI created in Interface Builder in a single MainWindow_iPad.xib. There are no other xibs, just UILables and UIButtons placed directly in MainWindow_iPad.xib and no view controller was used again.
Now, a couple of years later, I want to update this veteran app a bit. I want to add a root view controller so I set window.rootViewController in UIApplicationDelegate's didFinishLaunchingWithOptions. I have no problem with the iPhone version, it works a treat. But I have troubles with the iPad one. After setting window.rootViewController, the app doesn't interact to any touch at all. It loads, the UI is created but it's just frozen.
Any idea what could be wrong? Thanks a lot!
Don't tell me I should throw it away and write it again from scratch in a normal "experienced way", I know this would be the best way but I don't need to update it that much to waste so much time.
I have been learning iOS development for a few days now. At this moment, I have questions over how the rootViewController is to be used. I searched the web for 3 hours yesterday looking for the answer which turned up quite a few results that never really answered my question.
I am trying to learn to program an app using code only (no storyboards/xib files). I currently am trying to understand how to properly switch between views without using the UINavigationController. In my project I have the main delegate which creates the window, initializes my main view controller (which loads the separate view as well) and adds it as the rootViewController.
My first view has a button which calls a function in its controller to switch to my next view. Here is where my question arises: Do I switch the main rootViewController to the next view or do I load the next view as a subview of the rootViewController? Is the rootViewController supposed to encase all the views for an application? (I think this is how the UINavigationController works)
I have gotten switching of the rootViewController to work in my app, but I want to make sure there isn't some other way I am suppose to manage my views.
I would not switch the rootViewController, I think that should remain stable. So you could add it as a subview, or you can present it as a modal view.
And of course, you can just change the rootViewController to point to your new view if that's how you want to do it.
I’ve borrowed the Whereami code found in The Big Nerd Ranch iOS book and used it in the app I’m writing. My app determines the user's location and displays it in a map in the app delegate, just like Whereami app in the book does. The UIWindow is made visible and displays the map correctly. From this point on, the code is my own.
My app allocates a UINavigationController, sets the root view controller, and proceeds to allow the user to view other view controllers and perform other methods after navigating to them.
At some point, a view controller contains a button labeled “MAP” that, when pressed, should display the map showing the user’s current location.
How can I get the app to display the UIWindow that is in the AppDelegate.m? I assume the app delegate is continuing to determine the user’s location, and I want the user to have the ability to display the map at will.
My current code allocates a MapViewController when the “MAP” button is pressed, but I can’t figure out how to get the UIWindow which is in the AppDelegate.m to display.
I’m thinking I should be able to do it by having a pointer to the UIWindow in the MapViewController. Is this the right approach? Do I need anything else? I'm using Xcode 4.0.2, Snow Leopard, and testing on an iOS 4 device. I'm new at this, and I don't want to get confused by upgrading to Lion, a higher Xcode, or iOS 5 yet.
Consider using presentModalViewController:animated: (it's a method on all instances of UIViewController and its subclasses). There are a variety of transition styles you can use, like a flip or a fade.
On iOS you very rarely work with UIWindow objects. You pretty much set one up when your app launches and you leave it alone. Everything is done with UIView instances or the UIViewController instances that manage them.