What's the best way to develop a sideswipe men

2019-01-01 06:03发布

It appears that side-swipe menus are becoming a more common interface element as more information gets crammed into each iPhone app. Facebook has included it in their latest version and the new Gmail app appears to include it as well. I was wondering if anybody had thoughts on the most efficient way of developing something like this as it's becoming a more common interface element. While I have my own thoughts on how to build this, I'm curious to hear what other people think.

Facebook swipe navigation

18条回答
高级女魔头
2楼-- · 2019-01-01 06:38

There are tens of different libraries that developers have created to implement the Facebook/Path style navigation for iOS apps. I can list all of them but as you have asked for the best one, here are my two choices that i use to implement the side swipe navigation menu:

1) ECSlidingViewController Its very easy to implement and use Storyboards also. I haven't had any issues implementing it nor received any errors or anything like that. The link i provided has pretty much all the explanation in order to use it.

2) SWRevealViewController This library is easy to use and you can find a tutorial HERE, that shows how to implement it with all the explanation along with images. You can just follow the tutorial and thank me later.

查看更多
梦该遗忘
3楼-- · 2019-01-01 06:39

Facebook's implementation places a UIPanGestureRecognizer on the UINavigationBar. Thus allowing to catch swipes where it's needed.

That allows to do things like, recognizing the touch direction in x/z directly as well as the speed they occurred with.

Also such kind of tinkering with UIViews (more than one on screen at a time with evidently different tasks -> thus different controllers) should (I'm tempted to say must) use iOS new ViewController-Containment features. Every implementation without that is simply bad as it tinkers with the view hierarchy in a way not intended by Apple.

On a sidenote: If you're really curious on how it can be done as close to Facebook's way as possible, check out the project I open sourced on Github PKRevealController .

查看更多
梦该遗忘
4楼-- · 2019-01-01 06:39

Another option is to use Scringo . It gives you a side-menu like in youtube/facebook apps, and also all kind of built-in features in the menu that you can choose to add (e.g chat, invite friends, etc...)

Adding the side-menu is simply by calling [ScringoAgent startSession...] and all configuration can be done on the site.

查看更多
情到深处是孤独
5楼-- · 2019-01-01 06:40

If you want I did this repo on github GSSlideMenu It allow you to create a Facebook-style menu BUT with a "back" webView (generally all repos that I've found has a tableView as the "back" view).

查看更多
临风纵饮
6楼-- · 2019-01-01 06:43

This question is quite popular but it all came down to easy importing and use for me... Here is what I use... SWRevealController.

I'm surprised people miss it... It really is GREAT!!! and easy to use. The developer even includes a few example projects that allow you to see how to use it in different scenarios.

查看更多
泛滥B
7楼-- · 2019-01-01 06:45

Try adding your menu (that you swipe to get to) underneath the main view. Begin subscribing to touch events in the view.

Implement touchesMoved:, and check to see if the first gesture is vertical (scroll the main view, if needed), or horizontal (here you'd want to show the menu). If it's horizontal, begin invoking another method, - (void)scrollAwayMainView:(NSUInteger)pixels, whenever touchesMoved: gets called, calculating the number of pixels away from the starting point the main view should be, and passing that number into the method. In that methods implementation, run the following code:

[mainView scrollRectToVisible:CGRectMake:(pixels, 
                                          mainView.origin.y, 
                                          mainView.size.width, 
                                          mainView.size.height];
查看更多
登录 后发表回答