viewdeck / viewdeck Goto Github PK
View Code? Open in Web Editor NEWAn implementation of the sliding menu found in various iOS apps.
An implementation of the sliding menu found in various iOS apps.
An example would be a search like in the Facebook app on the iPhone
The panning action gets mixed up with adjusting volume and instead of setting the volume, it moves the centerviewcontroller. How can I fix this?
This can only be simulated on device.
I don't know if this should be a "feature" added to the ViewDeck class, or it should be something that we took care of, but in any case I think it's worth mentioning, cause it's an interesting issue which I can't really find a solution for.
Imagine this case: the center view controller has a UITextView for instance, and it opens the keyboard when the user taps on it and it becomes first responder. If I drag the view to show the left menu, the keyboard hides the whole screen. Can you think of ANY way to make whoever the first responder is resign as first responder when the menu is going to be shown?
Thanks in advance :) (and good job btw with the latest updates!)
I have a app consisting of a tabcontroller and several nav controllers...
In a table view (contained in a nav controller) I have the following code;
WebViewController web = [[KPMGWebViewController alloc]init];
web.article = [APPDEL.datamodel.toc objectAtIndex:indexPath.row];
IIViewDeckController deckController = [[IIViewDeckController alloc] initWithCenterViewController:web leftViewController:nil rightViewController:nil];
deckController.navigationControllerBehavior= IIViewDeckNavigationControllerIntegrated;
NSLog(@"pushing from %@",self.navigationController);
[self.navigationController pushViewController:deckController animated:YES];
This works great in ios5 but in ios4.3 the "web" is not load (ViewDidLoad is not called) and the screen is blank save for the navbar and tabbar...
Hi there,
First thing first: my compliments: very good job indeed!
I found a bug (or at least I think is not the expected behaviour.
When I start the app, the ViewDidLoad method of the centerViewController gets called twice.
Here's how I setup the ViewControllers in the App Delegate:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *centerViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UIViewController *sideViewController = [[ViewController alloc] initWithNibName:@"SideViewController" bundle:nil];
IIViewDeckController *deckController = [[IIViewDeckController alloc] initWithCenterViewController:centerViewController rightViewController:sideViewController];
self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];
return YES;
Starting in portrait rotation:
This can be easily reproduced by added a simple viewcontroller to the test project and in it's viewwillappear and viewwilldissapear hide and show the status bar. I just re-used the camera button to hide/show the testview.
I'm using closeLeftViewBouncing with a completion block that reassigns centerController while the center is offscreen, and I noticed that the newly centerController view actually starts out 20 pixels higher it should, and animates down as it slides back to the left.
this is very noticeable under the simulator if you turn on slow animations.
Also noticeable on the phone itself, as it makes the animation feel jerky/jumpy.
I'm switching between 3-4 different UINavigationControllers.
It's not really important as this controller lives along with the app, but it can be if you get a memory warning and it gets deallocated. You seem to be leaking the main view:
(void)loadView
{
_viewAppeared = NO;
self.view = [[UIView alloc] init]; // + 1 + 1
self.centerView = [[UIView alloc] init]; // +1 + 1
[self.view addSubview:self.centerView];
self.originalShadowRadius = 0;
self.originalShadowOpacity = 0;
self.originalShadowColor = nil;
self.originalShadowOffset = CGSizeZero;
self.originalShadowPath = nil;
}
Hope that helps :)
I’ve recently added ViewDeck to the CocoaPods package manager repo.
CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.
However, ViewDeck doesn't have version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.
Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.
I'm running with panningMode set to IIViewDeckNavigationBarPanning, and when I am in a screen with the keyboard up, it is possible to pan over to the left view.
The keyboard stays where it is though, and the center view slides to the right, which is definitely confusing.
Kinda feels like it might be a good idea to disable panning while keyboard is up. Maybe an option where IIViewDeckController listens for keyboard show/hide notifications and disables panning while keyboard is up?
leaks happened when gesture begin .
wish you can fix it
First of all: GREAT, AMAZING, OUTSTANDING JOB you did with IIViewDeckController, my congratulations :)
I'm using it in my next app ;)
I implemented it today, and have a few more details to comment which I'll add over here when I have a spare minute. For now let me just add that the delegate should set all the methods as @optional, to quite the compiler warnings, since as I see you're checking if the delegate implements them anyway :)
Thanks a lot! Keep up the great work! :)
I've integrated ViewDeck - very cool experience - and for the most part I have been able to work around integrating other projects that assume as standard IOS UIKit implementation.
One issue that baffles me, however, is a repainting issue with UITextView. It only happens when I use ViewDeck to own the UIViewController containing the UITextView.
On launch of the app, I display a UIViewController that contains a UITextView with content in it. All content is shown properly. This UIViewController is the "center" or "main panel".
Just like Facebook's app does, I have a trigram in the upper left nav bar, and the user can slide the center panel away to see a menu in a UITableView. All good here too.
However, when the user reselects the menu item to display the original center panel, the UITextView:
This issue only happens when I'm in the ViewDeck model. I'm a fairly experienced developer and have tested all sorts of things, including repainting the UITextView in a delayed performSelector after all the animation for the ViewDeck is completed. No luck.
The only thing that repaints the UITextView is when the user rotates the screen.
Any ideas what could be going on?
If you bring up the camera in ViewDeckExample and rotate, the camera view gets all messed up.
I think this is because IIViewDeckController shouldAutoroateToInterfaceOrientation doesn't honor whether or not a modal view controller on the center controller wants to allow rotation.
This patch fixes it, and stops the camera (UIImagePickerController) from rotating around and getting all confused.
Also fixes same issue I ran into in my app.
However, there is definitely a different behavior when running under IIViewDeckController and a standard controller for my app and modal view controllers (even with this fix):
A. with IIViewDeckController and this patch:
B. same app without IIViewDeckController
minor issue of course, but does make me wonder if there is a better fix.
Also wondering what happens when there is another modal view controller on top of the model view controller, etc. i.e., should we find the topmost modalViewController and ask it if we are allowed to rotate).
if (self.centerController) {
- // let the center controller handle the rotation behavior
- BOOL should = [self.centerController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
+ BOOL should;
+ if (self.centerController.modalViewController) {
+ // let the center controller modalViewController handle the rotation behavior
+ should = [self.centerController.modalViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
+ } else {
+ // let the center controller handle the rotation behavior
+ should = [self.centerController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
+ }
return should;
}
Similar to MWFSlideNavigationViewController. (I like your implementation better!)
I experienced some strange behavior, that is in editing mode I can't reorder UITableViewCell, when I tried to drag it to other position I will lose focus and the cell move back. Here is video showing the problem http://www.youtube.com/watch?v=ugxuLNL7BnU&feature=youtu.be
After I setPanningMode: the problem go away.
Hi,
Just wondering why the examples/the view deck doest render correctly on the iPad?
In my app, when I change the centre view controller the above method is not being called and I can't work out why. I've looked at all your examples, when the tab bar one in your development branch and they all call the method and I can't see why mine doesn't!
It's probably a really stupid issue with an extremely simple answer but the code I'm using to change the center view controller is:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == COMBINED) {
[self.viewDeckController closeLeftViewBouncing:^(IIViewDeckController *controller) {
CombinedNewsViewController *newsCombinedList = [[CombinedNewsViewController alloc] initWithNibName:@"CombinedNewsViewController" bundle:nil];
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:newsCombinedList];
self.viewDeckController.centerController = navController;
}];
} else if (indexPath.row == SOURCES) {
NewsFeedListViewController *newsFeedList = [[NewsFeedListViewController alloc] initWithNibName:@"NewsFeedListViewController" bundle:nil];
[self.viewDeckController closeLeftViewBouncing:^(IIViewDeckController *controller) {
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:newsFeedList];
self.viewDeckController.centerController = navController;
}];
}
}
If it makes any difference, viewDidLoad is called! However I also need viewWillAppear!
If I set the deckController.centerhiddenInteractivity to IIViewDeckCenterHiddenNotUserInteractiveWithTapToClose
then the center view gets stuck a few pixels from the left while panning to open the left view. when i pan again it finally opens.
ARC enabled
tested on iPhone 4s on iOS 5.0.1
The problem occurs in both Sizable Example and Tabbed Example (#define TABBAR_ENABLED NO), the views become messy on orientation changed
Hi
Again, this is probably a simple question so I apoligise up front.
I'm using the tabbed example in your dev branch and on my viewController1 I have a rightBarButtonItem, however, when I switch to my viewController2 I can't seem to add a different rightBarButtonItem, it always has the same one from viewController1.
Is there a way of changing the bar buttom items?
Hi,
I have an iAd in the center view controller. When the iAd activates then dismisses, the center controller is blank. How would I properly integrate iAd with this library? Thanks.
When a view is placed in the center view and then the device is rotated.
The following method is never called.
}
Tapping status bar does not scroll table view to the top when using navigation controller as central, left or right view controller.
Is there any possibility of using the IIViewDeckController with an app using Storyboarding? I would be fantastic to use it.
I must admit I implemented a controller like yours a couple of weeks ago, and had this issue too, and didn't quite discover a way to accomplish this. In the end I decided to stop developing my controller and use yours as it was less buggy and more complete.
But the question is: have you thought of this?
I think tapping the status bar is a pretty usefull feature in iOS, and it's annoying not to be able to do it :S
What I've been wondering is..... why does it work when it's a table view (or scroll view) inside a UINav controller for instance, but not when it's insice a custom controller? what's the difference with that?
Let me know if you find out what could be done about this...
Thanks a lot!
The navbar has a black space at the top :S
UIViewAnimationOptionCurveEaseInOut should be UIViewAnimationOptionCurveEaseOut
if using UIViewAnimationOptionCurveEaseInOut, the animation will slow to normal, the animation effect is not OK
the method closing right view or opening right view should be check too.
Hey.
I'm trying to figure out if this nice component could be used in conjunction with the TTNavigator component of Three20.
I tried to set up root controller of the window to a viewController , in which I actually use the TTNavigator.
self.leftMenuController = [[LeftMenuController alloc] initWithNibName:@"LeftMenuController" bundle:nil];
self.rightMenuController = [[RightMenuController alloc] initWithNibName:@"RightMenuController" bundle:nil];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.deckController = [[IIViewDeckController alloc] initWithCenterViewController:self.viewController leftViewController:self.leftMenuController rightViewController:self.rightMenuController];
self.window.rootViewController = self.deckController;
/**** and in the ViewController.m *******/
navigator = [TTNavigator navigator];
navigator.window = [[UIApplication sharedApplication] delegate].window;
map = navigator.URLMap;
[map from:@"tt://view2" toViewController:[TestView2 class]];
=>>The new controller TestView2 is being pushed but seems to replace the deckController since I can't use my left and right menus anymore. I am trying to find a way to combine both components so that the side menus are reachable anytime.
IIViewDeckController and any subsequent viewcontrollers are never deallocated (compiled without ARC)
Currently the library will only compile with LLVM 2.1+
I know this is a longshot, but have you looked at or thought about allowing for compiling with GCC 4.2?
My centerVC is a storyboard , and the firstVC of the storyboard is a navigation controller.
At first I edited addPanner and removePanner to fit that.. but:
I think that it could be nice if there was a UIView property that attaches the gesture recognizer (could be a tab bar / navigation bar or even a custom view).
The code is pretty simple (sorry , i'm fresh on gituhb , don't know how to "pull"/"fork"/etc. to do it myself) :
in .h file :
typedef enum {
IIViewDeckNoPanning, // no panning allowed
..
..
IIViewDeckCustomPanning
} IIViewDeckPanningMode;
//ADD:
@property (nonatomic,retain) UIView* panningView;
in .m file :
- (void)addPanner {
switch (_panningMode) {
case IIViewDeckNoPanning:
break;
...
//ADD:
case IIViewDeckCustomPanning:
self.panner = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panned:)];
self.panner.delegate = self;
[self.panningView addGestureRecognizer:self.panner];
break;
}
}
- (void)removePanner {
//ADD :
if (_panningView) [self.panningView removeGestureRecognizer:self.panner];
}
Please tell me if you like it , I have a working version.
I tried setting the panningMode property to IIViewDeckNavigationBarPanning in the ViewDeckExample project, but it does not work. Default panning (touch anywhere) works. This is with latest XCode 4.3 beta and simulator 5.1
This looks awesome. Especially since I'm currently working on my own solution and you'rs offers more options and a pretty clean API. One thing I'm missing is iOS 5's containment API which would make the whole thing less hacky and would remove the need for forwarding view controller methods.
I've got an error in LeftViewController, line 151:
-[LeftViewController topViewController]: unrecognized selector sent to instance 0x6b62080
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LeftViewController topViewController]: unrecognized selector sent to instance 0x6b62080'
It happens, when you are in "Swipe Left & Center"-Mod, wipe the fullscreen tableView to the right, so the TableView with the toolbar appears under it, and then select any cell of the fullscreen tableView.
Hi
In the TabbedExample, the left view controller, the one with ABCD, start position is partly hidden by the status bar, e.g. the first row of the table is partially hidden.
looks like a recent changed changed the behavior of presentModalViewController to use viewDeckController if set, but doesn't also do the same for dismissModalViewControllerAnimated.
I have code that does:
[self presentModalViewController:navCon animated:YES];
and then later calls:
[self dismissModalViewControllerAnimated:YES];
which no longer dismisses the modal view controller, since it was actually presented on viewDeckController.
If the overridden presentMVC* uses viewDeckController, then dismissMVC* must also do the same.
In the description in README, you said:
The library currently requires ARC. This means you can use it only for iOS5 projects.
However, this is not true because ARC is actually iOS4-compatible.
To verify, I just modified the deployment target setting, and it went well on both my device, and simulator.
Good work! :)
Really love ViewDeck - great work!
I have a feature question/request. I can't seem to find a way to disable the swiping gestures that can be used to reveal the side panels. I want to use conflicting gestures to navigate content. For example, when I swipe right it reveals the left view while at the same time executing my gesture recognizer code. Is this a feature I missed? What would you suggest?
Can you make a tutorial with storyboard about how to make the features example app? Looking at the source code doesn't seem to work properly for new projects that use storyboard instead of xibs.
[self.view removeObserver:self forKeyPath:@"frame"];
Accesses the view with the getter which calls loadView.
Also I would put the viewDidUnload call to super at the end of it.
Sorry for my rudimentary questions.
I ran the ViewDeckExample, the viewDeckController property returns "nil" on the left/rightViewConttoller.
So it didn't work like the demo(http://vimeo.com/34538429), didSelectRowAtIndexpath on leftViewContoller.
Please tell me what should I do anything.
When using the following code, the UITabBarController that I'm using is not hidden:
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:nextViewController animated:YES];
self.hidesBottomBarWhenPushed = NO;
If I create the UITabBarcontroller without IIViewDeckController in my app delegate then the tab bar is hidden.
I create by UITabBarController by using the following code. It's just one tab, there are actually more:
//ViewDeck Setup
NewsNavigationMenuViewController *menuController = [[NewsNavigationMenuViewController alloc] init];
CombinedNewsViewController *combinedNews = [[CombinedNewsViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:combinedNews];
navigationController.navigationController.navigationBar.tintColor = [UIColor blackColor];
IIViewDeckController *revealController = [[IIViewDeckController alloc] initWithCenterViewController:navigationController leftViewController:menuController rightViewController:nil];
revealController.title = @"News";
//create an array of views that will be passed to our tabbar
NSArray *viewsArray = [NSArray arrayWithObjects:revealController, nil];
//Now create our tab bar controller
TabBarController *tabBarController = [[TabBarController alloc] init];
//then tell the tabbarcontroller to use our array of views
[tabBarController setViewControllers:viewsArray];
//then the last step is to add the our tabbarcontroller as subview of the window
self.window.rootViewController = tabBarController;
[window makeKeyAndVisible];
ViewDeck is an excellent example of a class that does what's described here:
http://blog.carbonfive.com/2011/03/09/abusing-uiviewcontrollers/
Consequently, there are subtle bugs that are hard to work around. Two examples:
It doesn't handle view controllers properly that hide the phone's status bar.
It allows view controllers on the navigation stack to rotate even when they shouldn't. I can reproduce this by pushing several view controllers that only display in portrait mode onto the navigation stack, followed by one that allows any orientation. The navigation controller is the view deck's center controller. Rotating the device to landscape mode with the one that allows any orientation works fine, but when the stack is popped to the controller that doesn't support anything but portrait mode, it is left in landscape mode and the UIViewController methods having to do with rotation are never called.
My workaround was to only allow the ViewDeck controller to be the main window's view controller when the left or right view is partially exposed, then to remove the ViewDeck controller and directly assign the left or right view to the window when fully open or closed. This will not work for all applications of the ViewDeck, but was sufficient for my particular application.
One example is a scenario with a left controller and a center controller, and the interactivity set to IIViewDeckCenterHiddenNotUserInteractiveWithTapToClose. Open the left controller, then slowly drag the center one back, not releasing until it is at the left edge. The code in "panned" will call showCenterView:YES, but the two cases will not test positive, since once the center dragging is complete the leftController.view.hidden is YES, so closeLeftViewAnimated is never called (and even if it was it wouldn't work since it is already closed) and the delegate methods are never called, so the delegate never receives viewDeckControllerDidCloseLeftView.
Hi,
Hope I'm not opening an useless issue due to my small knowledge in iOS development, but I'll try.
Everything works how I expect and helps me a lot. Just a little thing I can't figure out what I'm doing wrong, is when I change centerController from the leftController :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self.viewDeckController closeLeftViewBouncing:^(IIViewDeckController *controller)
{
self.viewDeckController.centerController = [[UINavigationController alloc] initWithRootViewController:[self.menuControllers objectAtIndex:indexPath.row]];
}];
}
Where menuControllers is an array of UIViewControllers (for the ease of registerting new items in my menu)
I got this small gap on top of my view when it come to change.
Do you have any idea where this come from, and tell me if I did something wrong by updating the centerController this way ?
Thanks for helping, this is for school project purpose :)
How to reproduce:
I have no idea how this would be solved, but I think it would be a nice improvement :)
Thanks!!
I am using ViewDeck with a UINavigationController (i am doing custom stuff with the backgroundView and using the titleView to display a UIImageView, perhaps this has something to do with it?). The setTitle: method fires due to the KVO telling it to (haven't dug in to why), setTitle: tries to set the title of center controller to nil (which already has a title of nil) and EXC_BAD_ACCESS occurs.
This does not occur on iPad with the same code, on iPad I am not setting a left bar button item, whereas I am in the iPhone. I am also using a MGSplitViewController as the root view controller for iPad, on iPhone the viewDeck controller is the root view controller.
I have locally changed my setTitle: method to this and it resolves it:
- (void)setTitle:(NSString *)title {
if ([self.centerController isKindOfClass:[UINavigationController class]]) {
UINavigationController *centerController = (UINavigationController *)self.centerController;
if (!centerController.title && !title) return;
}
[super setTitle:title];
self.centerController.title = title;
}
The following line of code in WrapController's loadView has a memory leak:
self.view = [[UIView alloc] initWithFrame:II_CGRectOffsetTopAndShrink(self.wrappedController.view.frame, [self statusBarHeight])];
due to the fact that self.view is declared as retain in UiViewController.h. The line should be changed to the following, I believe:
self.view = [[[UIView alloc] initWithFrame:II_CGRectOffsetTopAndShrink(self.wrappedController.view.frame, [self statusBarHeight])] autorelease];
Hi guys,
Thank you for this wonderful class.
I've tried to use it in an app of mine and I've encountered a strange behavior.
My hierarchy is: UIWindow > Tabbar Controller > View Controllers (view controller 0 is IIViewDeckController with my view controller set as center).
I've tried to animate a sort of fullscreen mode changing tabbar frame with the code below.
Without IIViewDeckController as container of my view everything is ok:
http://dl.dropbox.com/u/103260/ok.mov
When I try with IIViewDeckController as view controllers #0 of my tabbar seems the size is not animated (or layout is not updated?). The size still remain it...until I try to move, then the new size is applied (or view content is refreshed).
That's a demo:
http://dl.dropbox.com/u/103260/no.mov
PS. Note the shadow below my view (at the middle of the screen).
Any idea? Seems IIViewDeckController cannot respond to layoutSubviews or something like this when I try to animate frame of it's parent (the tabbar controller).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.