Code Monkey home page Code Monkey logo

Comments (12)

evnaz avatar evnaz commented on July 3, 2024

Hi,
Try to set allowLeftSwipe and allowRightSwipe variables of the sideMenu to false

from enswiftsidemenu.

yao23 avatar yao23 commented on July 3, 2024

Hi Evnaz,

  1. I changed the source code directly like:
    private var menuPosition:ENSideMenuPosition = .Right
    public var bouncingEnabled :Bool = false
    public var allowLeftSwipe : Bool = false
    public var allowRightSwipe : Bool = false

Left and right swipe are disabled, bouncing is disable neither, but why the side menu still slides from left instead of right? What should I do to make it slide from right side?

  1. Is it possible to customize the side menu height upon different page view, for example, there is bottom tool bar in home page, but other pages, so I want to make the side menu shorter in home page and longer in other pages?

Thanks.

from enswiftsidemenu.

yao23 avatar yao23 commented on July 3, 2024

I solved the 1st problem with setting menuPosition as right in ENSideMenuNavigationController init method like this in ObjCExample:

    public init( menuTableViewController: UITableViewController, contentViewController: UIViewController?) {
        super.init(nibName: nil, bundle: nil)

        if (contentViewController != nil) {
            self.viewControllers = [contentViewController!]
        }

        sideMenu = ENSideMenu(sourceView: self.view, menuTableViewController: menuTableViewController, menuPosition:.Right)
        view.bringSubviewToFront(navigationBar)
    }

How about the 2nd question? How to set up different height based on different pages? User constraint for side menu to bottom view?

from enswiftsidemenu.

evnaz avatar evnaz commented on July 3, 2024

If you use UITableView as a side menu view, you can set content insets:

tableView.contentInsets = UIEdgeInsetsMake(0, 0, toolBar.frame.size.height, 0)

from enswiftsidemenu.

yao23 avatar yao23 commented on July 3, 2024

How can I disable the switch page view animation, because my side menu slide out from right, the current switching page is also from right side, so I wanna show it without animation, just let the current page disappear and next one appear. I tried to change

            UIView.animateWithDuration(0.1, animations: { () -> Void in
                self.sideMenuContainerView.frame = destFrame
            })

to

                self.sideMenuContainerView.frame = destFrame

in ENSideMenu::toggleMenu() method, but it still doesn't work.

from enswiftsidemenu.

yao23 avatar yao23 commented on July 3, 2024

Hi Evnaz,

I update side menu table view part, add an variable currentIndex to get the current row in side menu, if clicked the side menu row whose page view is already open, then we close the side menu rather than load the page view again because we are already in the page. You can update it in the Objective C example.

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView setContentInset:UIEdgeInsetsMake(64.f, 0, 0, 0)];
    [self.tableView setBackgroundColor:[UIColor clearColor]];
    self.currentIndex = 0;
}

#pragma mark - UITableView Delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.currentIndex == indexPath.row) {
        // close side menu
        [[self.sideMenuController sideMenu] toggleMenu];
        return;
    }

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *destTVC = nil;
    switch (indexPath.row) {
        case 0:
            destTVC = [storyboard instantiateViewControllerWithIdentifier:@"ViewController1"];
            break;
        default:
            destTVC = [storyboard instantiateViewControllerWithIdentifier:@"ViewController2"];
            break;
    }
    if (destTVC) {
        self.currentIndex = (int)indexPath.row;
        [self.sideMenuController setContentViewController:destTVC];
    } else {
        // close side menu
        [[self.sideMenuController sideMenu] toggleMenu];
    }
}

from enswiftsidemenu.

evnaz avatar evnaz commented on July 3, 2024

To disable animation on switch view controllers set sideMenuAnimationType of navigation controller to None

navigationController.sideMenuAnimationType = .None

from enswiftsidemenu.

yao23 avatar yao23 commented on July 3, 2024

How to initialize ENSideMenuNavigationController or ENSideMenu in a NavigationController or UIViewController class instead of assign it as root view controller in AppDelegate.m, because it's the not the 1st page in my case.

from enswiftsidemenu.

yao23 avatar yao23 commented on July 3, 2024

I tried to create a new view controller and init in - (void)viewDidLoad() method like following,

MenuItemsTVC *sideMenuTVC = [MenuItemsTVC new];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *contentVC = [storyboard instantiateViewControllerWithIdentifier:@"ViewController1"];
ENSideMenuNavigationController *navVC = [[ENSideMenuNavigationController alloc] initWithMenuTableViewController:sideMenuTVC contentViewController:contentVC];
[self addChildViewController:navVC];
[navVC didMoveToParentViewController:self];
navVC.view.frame = self.view.frame;
[self.view addSubview:navVC.view];

It can shows the content view controller and side menu, the only part which doesn't work is that there is no response when click at the cell of side menu.

I log out the debug info when select the cell like:

#pragma mark - UITableView Delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ NSLog(@"cur idx:%ld, index path row: %ld", (long)self.currentIndex, (long)indexPath.row);
    if (self.currentIndex == indexPath.row) {
        // close side menu
        [[self.sideMenuController sideMenu] toggleMenu];
        return;
    }

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *destTVC = nil;
    switch (indexPath.row) {
        case 0:
            destTVC = [storyboard instantiateViewControllerWithIdentifier:@"ViewController1"];
            break;
        default:
            destTVC = [storyboard instantiateViewControllerWithIdentifier:@"ViewController2"];
            break;
    }
    if (destTVC) {
        self.currentIndex = (int)indexPath.row;
        [self.sideMenuController setContentViewController:destTVC]; NSLog(@"cur vc: %@", destTVC.description); NSLog(@"vcs num: %lu", (unsigned long)self.navigationController.viewControllers.count);
    } else {
        // close side menu
        [[self.sideMenuController sideMenu] toggleMenu];
    }
}

and it shows:
2015-05-22 16:34:27.158 FS[15532:588753] cur idx:0, index path row: 0
2015-05-22 16:34:31.775 FS[15532:588753] cur idx:0, index path row: 1
2015-05-22 16:34:31.777 FS[15532:588753] cur vc: <ViewController: 0x7ffbd15334f0>
2015-05-22 16:34:31.777 FS[15532:588753] vcs num: 0
2015-05-22 16:34:43.673 FS[15532:588753] cur idx:1, index path row: 0
2015-05-22 16:34:43.674 FS[15532:588753] cur vc: <ViewController: 0x7ffbd32afc60>
2015-05-22 16:34:43.674 FS[15532:588753] vcs num: 0

it seems view controllers are not in navigation controller stack anymore.

from enswiftsidemenu.

yao23 avatar yao23 commented on July 3, 2024

Is there any Objective C version published for this side menu?

from enswiftsidemenu.

evnaz avatar evnaz commented on July 3, 2024

You can use this control in a ObjC project. ObjC example is in the repo.

from enswiftsidemenu.

yao23 avatar yao23 commented on July 3, 2024

I tried integrate the side menu like OjbC example which is the very first controller and it works. But I added it in my current project flow which shows the first content page of side menu after user sign in, it can show and hide side menu and it can also log out the cell index number when click at the side menu row, but it cannot direct to the target page (view controller) like example. Is it because the side menu nav controller is not first entry and side menu not well configured?

I tried to create a new view controller and init in - (void)viewDidLoad() method like following:

MenuItemsTVC *sideMenuTVC = [MenuItemsTVC new];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *contentVC = [storyboard instantiateViewControllerWithIdentifier:@"ViewController1"];
ENSideMenuNavigationController *navVC = [[ENSideMenuNavigationController alloc] initWithMenuTableViewController:sideMenuTVC contentViewController:contentVC];
[self addChildViewController:navVC];
[navVC didMoveToParentViewController:self];
navVC.view.frame = self.view.frame;
[self.view addSubview:navVC.view];

from enswiftsidemenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.