Layered viewcontroller for iPad - objective-c

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

Related

Create custom animated segue with images?

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.

Poor UITableView performance when in UIPopoverController with custom background

I have a following situation (testing on iPad, iOS 5.1):
There is a UIPopoverController with UINavigationController inside and custom popover background view (subclass of UIPopoverBackgroundView).
There is a generic UIViewController (let's call it VC1) as the root VC in the Navigation Controller.
I push another UIViewController (VC2) with UITableView on the Navigation Controller stack.
Effect:
Table scrolling is choppy (looks like 10-15 fps). For testing purposes I use a simplest possible UITableView, without images etc. so it's NOT caused by bad UITableView implementation.
Scrolling is not choppy if the VC2 is the root view controller of
Navigation Controller, even with the custom Popover background.
It's also not choppy if pushed as the second VC but I don't use custom bg view class for UIPopoverController.
I log each of the overriden methods inside my UIPopoverBackgroundView subclass, and they aren't called constantly or anything, which could theoretically cause performance hit. I'm going to debug the problem further but maybe someone has already solved it before?
Or maybe someone has good suggestions on how to find the culprit? I tried looking into time profiler for offending function calls, but I didn't find much there...

Subview vs childViewController

This is a general question but I'll ask it using a specific example to avoid confusion:
I'm developing an app that has a UIPickerView among other things on a single screen. I was wondering if it's appropriate the make a custom PickerViewController class to control my UIPickerView and then add my PickerViewController as a childVC...
OR should I just create an instance of UIPickerView in my existing VC and control it from there?
When should I do either of these options and what are the advantages of them?
Appreciate the help amigos.
If the UIPickerView is simoultaneously on the screen along with other UI elements, then you should just add it as a subview. The concept of a view controller is for when you start managing a completely different UI/window/set of elements (however you call it). If the picker view closely belongs to the functionality of the other elements, you should not create a separate view controller for it.
iOS 5.0 introduced the notion of child view controllers. Originally, any view controller except for UINavigationController and UITabBarController had to be modal and full screen. In iOS 5.0, you can now have several UIViewControllers present on one screen. This means that one UIViewController can have many children (UIViewController), where each child is responsible for controlling more specific views and models.

Stick UISplitViewController in its own XIB?

my iPad app starts with a normal UIView showing a login. After the user logged in the screen is supposed to switch to a split view.
XCode's SplitViewTemplate (and all examples on the web I found) however, place UISplitViewController in the main window's xib and define an outlet in the app delegate.
I find that unlogical in my case because I don't need the controller at startup and would like to (following Apple's guidelines) place the split view controller in its own XIB.
Has anybody a working example or a small step by step instruction? I always end up with the XIB not being loaded.
Or is it just NOT possible? But why would it not?
René
You can put a UISplitViewController into a different XIB. You cannot have it be the owner, but you can have your app's delegate be the owner and load it when it removes the login view.
Add UISplitViewController IBOutlet to app delegate
Create a new, empty XIB for iPad
Set the File's Owner to your app delegate class
Add a UISplitViewController, connect to outlet in delegate
Add views to split vew controller
Then, you just have to handle your login in the app delegate, load the new XIB, and display it.
maybe not the answer to your question but I have in my App also a login window. What I do is to put the login view above - in my case - TabBar.
I found this post. Best way to switch between UISplitViewController and other view controllers?
It seems it really is not supposed to work. You have to put it in the main xib and then apply tricks...

When I open a custom UIView from a UITableViewController, how do I close the custom view and go back to the table view?

I'm using a UITableViewController for a menu in a game. The table view opens a a view controller for my custom UIView that shows the game. When the game finishes the UIView is notified (which is kinda ruining the MVC principals) and from there I am kinda lost.
Questions:
Can a UIView communicate with its controller? How?
Can one controller talk to the one that started it? How?
How do I transition between all of this complicated web of views and controllers gracefully?
Use a delegate protocol here. Your custom game UIView can use a delegate property and call methods on this delegate when events happen (game over, game paused, view closed, etc). Here's a great post on using delegates: How do I create delegates in Objective-C?
I'd recommend using a UINavigationController. You don't necessarily need to show the navigation bar, but if you nest your view controllers in a navigation controller you have access to -pushViewControllerAnimated: and -popViewControllerAnimated: which make it really easy to navigation between levels of nested view controllers.
Another benefit of UINavigationController - you'll get a nice slide animation when you switch between views.
There are other 3rd party mechanisms out there that you may prefer over the UIKit UINavigationController/UIViewController mechanisms. Check out the Three20 project, in particular the TTNavigationCenter class.