dekatotoro / slidemenucontrollerswift Goto Github PK
View Code? Open in Web Editor NEWiOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.
License: MIT License
iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.
License: MIT License
Hi,
I can't pushviewcontroller, I use your method which is called changeviewcontroller, so I cant use poptorootviewcontroller. What should I do to reform for this situation.
Thanks,
Haydar
Hi guys, I'm new in swift dev.
I'm trying use this amazing lib, but I can't.
My appdelegate.swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let windowSizes = UIScreen.mainScreen().bounds
var leftViewController: UIViewController = UIViewController()
leftViewController.view.frame = CGRectMake(0, 0, 300.0, windowSizes.size.width)
leftViewController.view.backgroundColor = UIColor(hexString: "#FF0000")
var mainViewController = NavigationViewController()
// MARK: Side Menu
let slideMenuController = SlideMenuController(mainViewController: mainViewController, leftMenuViewController: leftViewController)
self.window?.rootViewController = slideMenuController
self.window?.makeKeyAndVisible()
return true
}
What am I doing wrong? How I said, I'm new in iOS dev. Thanks!
If you only want to have one menu.
Hi dekatotoro, thanks for your work!
I'm using your SlideMenuController (customized to use UIStoryboardSegue to connect any UIViewController with left or right menus, so I can prevent to write code) and I want to update the options values from the self.options class.
These values are defined like let so they are not assignable.
I suggest to you to replace these "let" to "var", so we can edit the options values before the "self.initView()" function, when our class inherits from the SlideMenuController.
Enjoy!
Hi,
firstly congrats for great work.
So can someone explain me how add images into Slide Menu?
Thanks a lot
when i import showing No such Module.
When i get the SliderMenuControllerSwift from cocoapods, i can't use it since the imports doesnt work. Im am able to "Import SlideMenuControllerSwift" but i dont have any method SlideMenuController(mainViewController: mainViewC ... can you have a look at it?
when the left bar show up ,the main view's status bar become invisible , how to make it appear??
thank you ! ur code is great
Hi,
i'm new in iOS and swift.
I'm trying to call your menu from a page that is not my initial page but is not linking my button to the SlideMenuController class.
I would like to call the createMenuFunction from a UIViewControl called programmatically and not from the AppDelegate.swift
Is it possible? How to do this?
Thanks a lot
Hi dekatotoro,
congratulations for excellent work!
Just a question. I'm new in swift and in iOS programming ...so sorry for idiot question.
If i want change (into your sample app) MainViewController with a TableViewController?
I've tried to do this replacing MainViewController with MainTableViewController but i've an correct error in appdelegate here: leftViewController.mainViewController = nvc
Please can you help me?
Thanks a lot and best Regards
Hello . Entering the view NonMenuController.swift , the left slider function does not work quite the way it promised. But by turning the iphone, it activates the slide function. In other words , I wondered how to disable anyway , regardless of the rotation , the slider function. I wonder how to solve it . Thank you.
Hi, great work, I'm new to swift and wondering if you could provide a little insight as to how to set this up without instantiating the viewControllers from the storyboard, and integrating it with an already in process app?
Hi, great controller I'm having this issue at the moment:
If the previous controller is in editing mode (Keyboard up) when you change to the new screen, the Keyboard remains on screen.
Hi, first off thanks so much for taking the time to write out a thorough example. This has really helped me get started with IOS development.
My question comes as a result of me linking one of the pages to another page via a 'show' segue. Upon doing so, the top bar appears to turn into a navigation bar, and it overrides the left/right slider icons. I'm wondering how I could keep them on-screen for the initial page before I click into a nested page.
I write everything like almost your project in my project.First of all i would like to tell my stage before the error
There are 4 controllers in my slide menu.So, there will be 3 menus and 1 button.
Please Check - > http://puu.sh/it83l/1af3a63f09.png
Because of i set "Auction Latest" in AppDelegate like yours,it will be display first in the MainViewController.
Then
->I slide out the menu and tapped "Auction Latest" again,that view display at Main View again,
->Then I slide out and tapped "Auction Past" again,that view display
->Then "Auction Recent",that display again(Note:These state are important)
Then I tapped "Sign In" button on my slide menu,It will present modally over slide menu
Please Check -> http://puu.sh/it7Z0/adaf9a4247.png
You will see cross "X" button on the SignInView.When i click,it dismiss and you will see the left menu again.
So the problem is,every time i dismiss the sign in view which presented modally,the menu(views) that i visited "viewDidAppear()" called again.I wonder why?
Here is my console log after i dismiss my modally presented sign in view
Auction : Latest viewDidAppear
Auction : Latest viewDidAppear
Auction : Past viewDidAppear
Auction : Recent ViewDidAppear
Please check your slide menu again Sir,thanks.
I have been using your slide menu for my project since the beginning.
こんにちは。
ライブラリーどうもありがとうございます。
(日本語で申し訳ありません。)
さっそく質問ですが、
Gesturesでスライドメニューを表示させると、
viewDidAppearとviewWillDisAppearが呼ばれます。
メニューアイテムをタップしてスライドメニューを表示させると、
viewDidAppearだけ呼ばれて、そのごタップしても何も呼ばれません。
そのご、Gesturesでスライドメニューを表示させると、viewWillDisAppearだけ呼ばれます。
ごれは仕様でしょうか。
Line: 55 -> Source/SlideMenuController.swift
var leftTap`Getsture`: UITapGestureRecognizer?
should:
var leftTap`Gesture`: UITapGestureRecognizer?
This is working perfectly with the SlideMenuController as the rootViewController, however, I have a login view before that and I can't seem to get it to work without setting it as the rootview.
How would I go about doing this?
Appriciate any help :)
Hey there,
Thanks for making this, it's exactly the effect I've been looking for!
I have a problem trying to integrate this with my project. This is my current app structure:
Navigation Controller -> MainViewController
Inside MainViewController I have a button that calls:
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("GoalVC") as! GoalViewController
self.navigationController?.pushViewController(vc, animated: true)
Now inside this GoalViewController instance, I want to show this slide menu controller from the right. I do this on a tableview cell selection:
initFormSheet()
if let mySlideMenuController = self.mySlideMenuController {
mySlideMenuController.openRight()
}
This is the initFormSheet function:
var mySlideMenuController : SlideMenuController?
func initFormSheet() {
if mySlideMenuController == nil {
let formSheet = self.storyboard?.instantiateViewControllerWithIdentifier("DisposableCategoriesVC") as! UIViewController
mySlideMenuController = SlideMenuController(mainViewController: self, rightMenuViewController: formSheet)
}
}
The problem is, when the tableview cell is tapped and the above code is executed, nothing happens. My status bar gets hidden, but I don't see any view controller sliding from the right. Can you help me out here please? Can you tell me what I'm doing wrong?
I don't want to use your library for the root window, instead this is inside of a navigation controller sub window.
Thanks
when switch to view controller agin, tap on scroll (for scroll to top) in tableview does not work!
Hi Good Day,
How to use this library to be able to show it on the existing navigationcontroller?
Lets say we have a logincontroller on the navigationcontroller. After login I want to show this SlideMenuController which uses only the right. Can you give me sample code?
Thanks in advance!
First thank you very much for the great work you have done. I need to add navigation controller to left and right panel. How can i add navigation controller to left and right panel. Please help!
When i tapped Swift menu,it show me Swift View Controller.When i slide out to view the menu again
http://puu.sh/hW37U/4717187aa2.png
how to know the current view in my foreground?
http://puu.sh/hW38R/10b1d40bd5.png
Thank You
With Regards.
Hi, Thanks for this library, I have this scenario, first is login or register, after is home screen with slide menu, how can i use this library in this situation? i did it as home screen is launcher screen, thanks!
when the right panel is open, then i drag view from left to right. the method gestureRecognizer(shouldReceiveTouch touch:) runs, and the gestureRecognizer is leftPanGesture, and return true. but the handleLeftPanGesture action does not run. i don't understand that. could you tell me why?
Thanks for writing this great menu. I am just learning and this is so helpful.
It is clear and very well written.
Would there be a way to disable the both the menus ? Say, during a login/logout screen ?
And how would you suggest I switch to another viewController for this login/logout process.
I am not an advanced user. Any help is appreciated.
Great job !
I really like your work and I appreciate it. But I found some difficulties while working with your SlideMenuController. I implement the same way as your example but my navigation bar is not showing. Could you help?
From collection view I want open screen with menu. I use this code
// MARK: - UICollectionViewDelegate
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let vc = createMenuView()
self.presentViewController(vc, animated: true, completion: nil)
}
// MARK: - Create menu
func createMenuView() -> SlideMenuController {
let mainViewController = kStoryboard.instantiateViewControllerWithIdentifier("TakeLesson") as! TakeLessonViewController
let leftViewController = kStoryboard.instantiateViewControllerWithIdentifier("LeftViewController") as! LeftViewController
let nvc: UINavigationController = UINavigationController(rootViewController: mainViewController)
leftViewController.mainViewController = nvc
let slideMenuController = SlideMenuController(mainViewController:nvc, leftMenuViewController: leftViewController)
return slideMenuController
}
But in menu view I in TakeLessonViewController in willViewAppear write self.setNavigationBarItem() but this don't work. I used this method in viewDidLoad but have negative effect with BarButton. He started in origin x = 0 and after got to normal position.
How can I fix that?
Best regards Oleksii
Hello,
I am using this library and I have trouble with PUSH ViewController.
Could you please help me to suggest how to use this lib with UINavigationController ?
Thanks
Hi Dekatotoro, first of all, thank you very much for making this library, is really easy to use and by far the best slide out menu made with Swift, that i could find.
So here's the deal, i'm trying to implement a Table View on my sidebar ( left view ) so i can create a simple menu.
I'm adding the tableview via storyboard, the view is being added on the app via AppDelegate.swift just like in the example:
private func createMenuView() {
var storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainView = storyboard.instantiateViewControllerWithIdentifier("mainView") as ViewController
mainView.addLeftBarButtonWithImage(UIImage(named: "menuicon")!)
let sideView = storyboard.instantiateViewControllerWithIdentifier("sideView") as SidebarViewController // this is the sidebar
let nvc: UINavigationController = UINavigationController(rootViewController: mainView)
let slideOutMenu = SlideMenuController(mainViewController: nvc, leftMenuViewController: sideView)
nvc.navigationBar.barTintColor = UIColor(red: 0.20392156862, green: 0.59607843137, blue: 0.85882352941, alpha: 1.0) //rgba(52, 152, 219,1.0)
nvc.navigationBar.barStyle = UIBarStyle.Black
nvc.navigationBar.tintColor = UIColor.whiteColor()
nvc.navigationBar.translucent = false
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
self.window?.backgroundColor = UIColor(red: 236.0, green: 238.0, blue: 241.0, alpha: 1.0)
self.window?.rootViewController = slideOutMenu
self.window?.makeKeyAndVisible()
}
The problem is the tableview is being added above everything, any idea on why this is happening
Thank you!
Let me say clear for the issue.
1.I was using "Main View Controller" for displaying data with images using Table View
2.In order to display the data with detail,i created "Detail View Controller" and make Navigation Embedded to "Main View Controller" to create segue for "Detail View Controller".
3.I disabled the your slide out at "Detail View Controller" because i don't want to.I only want to display Slide out at "Main View Controller"
So these are my program status
[issue]After I clicked "Back" key or swiped left gesture to come back to "Main View Controller" from "Detail View Controller",my slide out using left gesture is stopped working at "Main View Controller".Only the slide gesture is stopped working.But,when i click navigation bar item that you created to appear slide out view controller,it appear.
Please Help!!!I am using it in my automobile project
I'm having an issue when a phone call gets in and you are in the middle of a transition..
I'm still trying to find why this happen .
I want just the nav bar button to open but the pan gesture to close or tap back to other controller to close.
The entry point/initial view controller in my app is a TableViewController that presents a LogInViewController if not logged in, and dismisses it once the login succeeds. I'm using NSUserDefaults for the log in status (just a Bool returning true if logged in) for now. So when I open the app with it logged in, go to log out, and log back in, the slide menu won't come up on the TableViewController, either through the BarButtonItem or through dragging the screen from the side.
I'm not sure what's causing this, or even what code to show that's relevant to the issue. I was calling setNavigationBarItem() within viewDidAppear() in my TableViewController, but am now calling it in viewWillAppear() because using viewDidAppear() completely prevents the navigation bar from showing up on my TableView page. My TableViewController is a child of a NavigationController, and my LogInViewController isn't, it just segues directly to the TableViewController. I'm also noticing that viewWillAppear() is being called twice and haven't found a way to prevent that online, and am not sure if it's related to the fact that the slide menu isn't showing up once I log back in.
The code I'm using to present (from TableViewController.swift) and dismiss(from LogInViewController.swift) is:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("LogInViewController") as! LogInViewController
let navigationController = UINavigationController(rootViewController: vc)
self.presentViewController(navigationController, animated: false, completion: nil)
and
self.dismissViewControllerAnimated(true, completion: nil)
I don't know how much of this issue is on my end or if it's just something this library isn't designed to do. Please let me know if any more code would be helpful in solving this problem.
Hi! I'm really stuck with customizing.
Could you make a very light example of this menu, which toggle between different views?
This helps me a lot to discover Swift.
Thank you very much
i update xocde version to 7 , slideMenuController has many errors,could you helper me to fix these error in xcode7
Hi, can't find any other way to contact you, so I'm posting this as an issue, it actually is not, more a feature?
I'm fairly new to iOS Development and trying to user your SlideMenuControllerSwift on an application with tab bar controller. Everything works fine, except that the iOS default behaviour when doing segues is not working. What I mean: I tap a button which triggers a segue to another view controller. No the navigation bar at the top should enable a "< back" button by default, which it doesn't. Only on my first tab bar item.
Can you tell me, whether this can be "fixed"?
Thank you.
Thanks for this. I think I almost have it working.
My only problem is that I am trying to target UITabBarController
and UINavigationController
from my LeftMenu. Is there a way to make that work? Right now I get an error. I think it's because your code is looking for MainViewController
to be a UIViewController
.
Here's some of my code:
var menuItems = [:]
var menuSectionTitles = []
var myChildrenController: UINavigationController!
var recentActivityController: UIViewController!
var bathsController: UITabBarController!
var diapersController: UITabBarController!
var feedingsController: UIViewController!
var measurementsController: UIViewController!
var medicalController: UIViewController!
var milestonesController: UIViewController!
var napsController: UIViewController!
var pumpingController: UIViewController!
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
menuItems = ["":["My Children", "Recent Activity"], "Record Events":["Baths", "Diapers", "Feedings", "Measurements", "Medical", "Milestones", "Naps", "Pumping"]]
menuSectionTitles = menuItems.allKeys
var storyboard = UIStoryboard(name: "Main", bundle: nil)
let myChildrenController = storyboard.instantiateViewControllerWithIdentifier("MyChildrenViewController") as! MyChildrenViewController
self.myChildrenController = UINavigationController(rootViewController: myChildrenController)
let bathsController = storyboard.instantiateViewControllerWithIdentifier("BathsTabBarController") as! BathsTabBarController
let bathsTimerController = storyboard.instantiateViewControllerWithIdentifier("BathsTimerViewController") as! BathsTimerViewController
let bathsHistoryController = storyboard.instantiateViewControllerWithIdentifier("BathsHistoryNavigationController") as! BathsHistoryNavigationController
let bathsTrendsController = storyboard.instantiateViewControllerWithIdentifier("BathsTrendsViewController") as! BathsTrendsViewController
self.bathsController.viewControllers = [bathsTimerController, bathsHistoryController, bathsTrendsController]
let diapersController = storyboard.instantiateViewControllerWithIdentifier("DiapersTabBarController") as! DiapersTabBarController
let diaperHistoryController = storyboard.instantiateViewControllerWithIdentifier("DiapersHistoryNavigationController") as! DiapersHistoryNavigationController
let diaperTrendsController = storyboard.instantiateViewControllerWithIdentifier("DiapersTrendsViewController") as! DiapersTrendsViewController
self.diapersController.viewControllers = [diaperHistoryController, diaperTrendsController]
// Uncomment the following line to preserve selection between presentations
//self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
Thanks for your help!
-Bill
thank you for your support.
i use 'self.slideMenuController()?.removeLeftGestures()'.
but that code was ignored on Landscape interface.
please check this issue.
thank you.
Why is this property hidden? It might be sometimes useful to have a reference to this view controller when transitioning.
Here is my scenario
VC1 calls app://VC2
UIApplication calls router
router matches the path
match block grabs the context object on the mainViewController
match block sets the context object on VC2
match block calls slideMenuController to changeMainViewController to VC2
Unless there is a pressing reason for this being hidden can we remove its private modifier?
e.g.
I'm having trouble allowing the first shown page to segue to another view automatically (if not logged in, go to login view, etc)
The problem from the example is that the LeftViewController passes in the LeftMenuProtocol as 'delegate' to the created views.
However, that is only done when the user opens a view from the left menu, not from AppDelegate. If a view is loaded in from AppDelegate, there seems to be no way (that i know of) to access LeftMenuProtocol.
Some help would be appreciated.
First of all, thank you for the awesome library. Saved me tons of effort.
I'm wondering if there's an easy way of adding a "slide from right" or "slide from left" animation to the main view controller (I am currently using changeMainViewController
to navigate between screens). Or is my only option to add the animation to the slideMenuController's code directly?
Hi there!
I love your slide menu controller, but I don't seem to find a way to use it together with the default navigation controller. What I mean is that I basically have many "Main" screens which will be accesed through the menu. As of there, everything's alright. But then, I want to be able to click on a button on those main screens that will take me to a second screen (A detail screen to the sake of the example), which HAS to allow me to go back using the "BACK" button included in the default navigation controller. Is there a way for me to do this?
Sorry to trouble you, and thanks again for your awesome plugin.
Project LeftViewController has a login_button, when click the button , the print self.navigationcontroller is nil whit an error , how to fix it ?
Hi
On non menu controller i am not able to add our back button,
Is there any to allow the back button, or how can i navigate the non menu controller, so that user can click on the back button and come back directly to home view controller.
Below is my code
import UIKit
class CategoryViewController: UIViewController {
var delegate: LeftMenuProtocol?
var categoryType:NSString!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
print(categoryType);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.removeNavigationBarItem()
}
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
coordinator.animateAlongsideTransition(nil, completion: { (context: UIViewControllerTransitionCoordinatorContext!) -> Void in
if let viewController = self.slideMenuController()?.mainViewController as? UINavigationController {
if viewController.topViewController.isKindOfClass(CategoryViewController) {
self.slideMenuController()?.removeLeftGestures()
self.slideMenuController()?.removeRightGestures()
}
}
})
}
@IBAction func backButtonAction(sender: UIBarButtonItem) {
delegate?.navigateViewController(LeftMenu.Home)
}
@IBAction func buttonAction(sender: AnyObject) {
delegate?.navigateViewController(LeftMenu.Home)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Im trying to use it with swift 1.2 and the code need some changes, will be updated? And also when be available through cocoapods?
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.