iphone facebook side menu using objective c [duplicate]
Asked Answered
D

1

30

Possible Duplicate:
What's the best way to develop a sideswipe menu like the one in Facebook's new iOS app?

The facebook iphone app has a new side menu,
screen
(source: tapscape.com)

Does anyone know how i can implement this feature in my iphone application and using objective c?

Dandy answered 3/11, 2011 at 6:27 Comment(2)
Check this library. Helped me! It is finished library doing that really good!Destructor
Very simple and easy to use github.com/shivamchove/facebook_style_left_menus libraryDepress
G
49

It's pretty simple really. First, you need to make a view controller that sits under the one that's visible. You can send that view to the back like this:

[self.view sendSubviewToBack:menuViewController.view];

Then, you put a menu button on the left side of your navigation bar, and write a handler kind of like this:

- (void)menuButtonPressed:(id)sender {

    CGRect destination = self.navigationController.view.frame;

    if (destination.origin.x > 0) {
        destination.origin.x = 0;
    } else {
        destination.origin.x += 254.5;
    }

    [UIView animateWithDuration:0.25 animations:^{

        self.navigationController.view.frame = destination;        

    } completion:^(BOOL finished) {

        self.view.userInteractionEnabled = !(destination.origin.x > 0);

    }];
}

That's the general idea. You may have to change the code to reflect your view hierarchy, etc.

Gerlach answered 9/11, 2011 at 0:8 Comment(10)
@Gerlach I'm confused on how you sent the menu to the back? When I do that it just shows a black side menu.Lewin
this worked for me, thanks! does anyone know how to handle orientation changes for this side menu?Holdover
can i do this for a tab bar view controller . basically planning to hide the tab bar in the bottomMerrick
This works when you have 2 UIViewControllers on top of each other and you move the one on top to the side to see the "menu" view under it. I need to have the one on top be a UINavigationController but cannot achieve this. Any help would be appreciated.Zillah
@Lewin Were you ever able to get the UIViewController underneath to become visible?Panhellenic
How do you add the childViewController's view as a subview? do you set its frame explicitly?Panhellenic
@Gerlach Whose subview is the childviewcontroller's view and what frame is it given?Panhellenic
@Piotr see https://mcmap.net/q/500332/-send-subview-to-back I also have appointmentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"AppointmentViewController"]; self.navController = [[UINavigationController alloc] initWithRootViewController:appointmentViewController]; self.navController.view.frame = self.contentView.bounds; [self addShadowToMenu]; [self.contentView addSubview:self.navController.view]; self.sideMenu.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; in my side menu viewDidLoadLewin
I added a button on side view, but when I am trying to click it, it is not responding to associated action :(Abert
Sorry, I didn't see all these questions until tonight. When I did this, I used UIViewController containment had a UIViewController that had two child UIViewControllers. The button on the "content" view controller would send a message up to the root container view controller and that would handle the animation.Gerlach

© 2022 - 2024 — McMap. All rights reserved.