handsomecode / interactivesidemenu Goto Github PK
View Code? Open in Web Editor NEWiOS Interactive Side Menu written in Swift.
License: Apache License 2.0
iOS Interactive Side Menu written in Swift.
License: Apache License 2.0
Hii Team ,
I have used your this control in my most recent work & it's working really nice except it goes blank or say white screen on iPhone 7 & 7+ while i open it from Left side button with didOpenMenu() function. i don't get it why it just happening only in this particular device only. please help me.
Thank you.
Hello, is showing menu from right supported? if so how to do it, thanks!
When I try to push ViewController I got an error:
Could not cast value of type 'TestApp.HostViewController' (0x106c025f0) to 'UINavigationController' (0x10b3763c8).
(lldb)
My code:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationViewController = storyboard.instantiateViewController(withIdentifier: "MarketShowViewController") as! MarketShowViewController
let navigationController = UIApplication.shared.windows.first?.rootViewController as! UINavigationController
navigationController.pushViewController(destinationViewController, animated: true)
When I create my menu item controllers, I embed them in navigation controllers.
e.g.
let text = TextViewController(textView: TextView.init(frame: UIScreen.main.bounds), pageID: page.pageid) let navigationController = UINavigationController(rootViewController: text) contentList.append(navigationController)
Issue is when I click one of these items, it loads, but the status bar vanishes and just leaves a black box.
How can i get the behaviour to work as expected and retain the status bar which then takes on the background colour of the navigation bar, as it would do outside of the side menu encapsulation
if present storyboard in UIViewController showSideMenu() not working
let presentAA = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "AA") as! AAViewController
self.present(presentAA, animated: false, completion: nil)
//not working
func menu() {
showSideMenu()
}
How can i achieve a wider recognition area for the menu pull out? currently by default its on the very edge of the view and it would be good to have a slightly wider area available
how can i do right menu ?
and also if it possible to change with according to the app locale language
when click on the side menu and click on the buttons first time it reload the Controller but if I Come again to that controller its not updated it show the last opening Thing how can I call reload the controller
if there is possible add a feature so that we simply change layout while the language is Persian or arabic
the menu open from left side so after adding that feature we may open from right side based on language
because the menu in this language should open from right side
Hi, I want to remove the damping effect in the open and close animations. How can I only set curveEaseOut animation for both? Thanks
Hi i'm still new in IOS development. a quick question, is there anyway to implement this into Nib? Since most of my modules I'm using Nib, so for me to implement this using storyboard very confusing for me. Thank you.
Hey,
I am having some trouble with InteractiveSideMenu.
I tried to use the framework for iPad running iOS 11, but there seems to be a problem; the first time I close the side-menu, my button moves about 20px to the top.
I attached some pictures of it. I am using the same constraints as in your official Sample project.
The console output:
[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x600000280550 UILayoutGuide:0x6000001b9360'UIViewSafeAreaLayoutGuide'.bottom == UITableView:0x7f8f3f823c00.bottom + 20 (active)>",
"<NSLayoutConstraint:0x600000280730 UITableView:0x7f8f3f823c00.centerY == UIView:0x7f8f3f400ce0.centerY (active)>",
"<NSLayoutConstraint:0x600000280780 UITableView:0x7f8f3f823c00.top == UILayoutGuide:0x6000001b9360'UIViewSafeAreaLayoutGuide'.top (active)>",
"<NSLayoutConstraint:0x600000280640 'UIViewSafeAreaLayoutGuide-bottom' V:[UILayoutGuide:0x6000001b9360'UIViewSafeAreaLayoutGuide']-(0)-| (active, names: '|':UIView:0x7f8f3f400ce0 )>",
"<NSLayoutConstraint:0x6000002805a0 'UIViewSafeAreaLayoutGuide-top' V:|-(0)-[UILayoutGuide:0x6000001b9360'UIViewSafeAreaLayoutGuide'] (active, names: '|':UIView:0x7f8f3f400ce0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000280730 UITableView:0x7f8f3f823c00.centerY == UIView:0x7f8f3f400ce0.centerY (active)>
This might refer to #53 , but I am not sure.
Hey guys,
Thanks for the great library.
Currently contentViewControllers
requires instantiated view controllers which could cause high memory usage specially with complex views. I tried to change it to array of StoryBoard identifiers and instantiate VC inside selectContentViewController()
which resolves the allocation issue and I can see that previous views gets de-initialized successfully but now I am having a UI Performance issue and changing the SideMenuItemContent seems a bit slow.
Have you tried to fix the memory allocation issue in another way or do you have any suggestions that can improve the overall performance impact ?
In my project the width of the menu view controller doesn't change to the visible size. Instead it just keeps the full size of the screen as you can see on the label which gets cut. Also I've attached the view debugger rendering of the same screen where you can see that there should actually even be a checkmark which is being overlapped by the content view though. How would I deal with that?
Hi, can this library be used for UISplitViewController project? I am going to build UISplitViewController that has slide menu that will push to respective ViewController based on the menu selected on the side menu. Thanks!
I currently use sidemenu and it instantiates its controller tabs when it inits.
Issue is i want to use a tab bar controller inside my first view controller tab, which can quick link me to 3-4 other controllers that are also in the sidemenu.
What approach is needed architecturally to allow for the tab bar controller to instantiate its controllers without overlapping with those created by the sidemenu?
Thanks
Following the example files, I have an issue where my view is blank white once I present the hostController, the ViewDidLoad is hit on both the menu and the home page (first VC in array) but there isnt anything visible.
From the below is the reason for this obvious? I push hostController with:
let hostViewController = HostViewController()
self.appDelegate.window?.rootViewController = hostViewController
Here is my setup code:
class HostViewController: MenuContainerViewController {
var manager = APIManager()
let appDelegate = UIApplication.shared.delegate as! AppDelegate
var sideMenuViewItems: [MenuItem] = [MenuItem]()
override func viewWillAppear(_ animated: Bool) {
getMenuItems(apiKey: appDelegate.apiKey, userID: appDelegate.userID, eventID: appDelegate.defaultEvent)
}
override func viewDidLoad() {
super.viewDidLoad()
let screenSize: CGRect = UIScreen.main.bounds
self.transitionOptions = TransitionOptions(duration: 0.4, visibleContentWidth: screenSize.width / 6)
// Instantiate menu view controller by identifier
self.menuViewController = NavigationMenuViewController(navigationMenuView: NavigationMenuView(frame: UIScreen.main.bounds))
// Gather content items controllers
contentViewControllers = contentControllers()
// Select initial content controller. It's needed even if the first view controller should be selected.
selectContentViewController(contentViewControllers.first!)
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
// Options to customize menu transition animation.
var options = TransitionOptions()
// Animation duration
options.duration = size.width < size.height ? 0.4 : 0.6
// Part of item content remaining visible on right when menu is shown
options.visibleContentWidth = size.width / 6
self.transitionOptions = options
}
private func contentControllers() -> [UIViewController] {
var contentList = [UIViewController]()
let dashBoard = HomeScreenViewController(homeView: HomeScreenView.init(frame: UIScreen.main.bounds))
contentList.append(dashBoard)
let welcome = TextViewController(textView: TextView.init(frame: UIScreen.main.bounds))
contentList.append(welcome)
let agenda = AgendaViewController(agendaView: AgendaView.init(frame: UIScreen.main.bounds))
contentList.append(agenda)
let poll = PollsViewController(pollsView: PollsView.init(frame: UIScreen.main.bounds))
contentList.append(poll)
return contentList
}
}
and my MenuViewController:
class NavigationMenuViewController: MenuViewController {
var navigationMenuView: NavigationMenuView!
var sideMenuViewItems: [MenuItem] = [MenuItem]()
var manager = APIManager()
let appDelegate = UIApplication.shared.delegate as! AppDelegate
var apiKey: String?
var user: User?
var userID: String?
var eventID: String?
init(navigationMenuView: NavigationMenuView) {
super.init(nibName: nil, bundle: nil)
self.navigationMenuView = navigationMenuView
self.view.addSubview(navigationMenuView)
self.view.setNeedsUpdateConstraints()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewWillAppear(_ animated: Bool) {
// remove nav bar from side menu
self.navigationController?.setNavigationBarHidden(true, animated: animated)
// pull app delegate values
configureUserDetails()
}
override func viewDidLoad() {
super.viewDidLoad()
print("THE MENU VIEW WAS LOADED")
// setup
navigationMenuView.menuTable.register(MenuItemCell.self, forCellReuseIdentifier: "MenuItemCell")
navigationMenuView.menuTable.selectRow(at: IndexPath(row: 0, section: 0), animated: false, scrollPosition: UITableViewScrollPosition.none)
}
}
extension NavigationMenuViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.sideMenuViewItems.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 43
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let menuContainerViewController = self.menuContainerViewController else {
return
}
menuContainerViewController.selectContentViewController(menuContainerViewController.contentViewControllers[indexPath.row])
menuContainerViewController.hideSideMenu()
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let menuItem = self.sideMenuViewItems[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "MenuItemCell", for: indexPath) as! MenuItemCell;
// styling
cell.backgroundColor = UIColor.clear
cell.selectionStyle = UITableViewCellSelectionStyle.none
// properties
let imageURL = URL(string: menuItem.icon);
cell.icon.af_setImage(withURL: imageURL!) // make safe
cell.titleLabel.text = menuItem.title
cell.titleLabel.textColor = UIColor.white
cell.badgeLabel.text = menuItem.badgeCount
// show/hide badge based on value
if(menuItem.badgeCount == "" || menuItem.badgeCount == "0" || menuItem.badgeCount == nil) {
cell.badgeView.alpha = 0;
}
else {
cell.badgeView.alpha = 1;
}
return cell
}
}
Just installed it through CocoaPods. Set my UIViewController to conform to MenuContainerViewController. And this XCode error appears: Use of unresolved identifier 'TransitionOptions'. And i couldn't find implementation for this in InteractiveSideMenu Pod classes. transitionOptions property is missing too. I compared the class MenuContainerViewController from Pod and from example from GitHub and they seem different! Could you please help me what am doing wrong?
I recently added InteractiveSideMenu through Cocoapods and I could not Set my UINavigationController protocol to SideMenuContent. And also to set the visible width I cannot see the TransitionOptions. Please Help!
I checked ChangeLogs and even forums, couldn't find any reference of anyone using it. Everyone uses the earlier version only. Even the changelog mentions use of TransitionOptions. How to go about it?
I have sign out button in side menu. when i click this button i want to pop to root view. How i can do this ?Kindly support asap.
Thank you.
Smartberrry
I want to preserve the state of my view controller if it is currently selected because all the data in my Table View will be gone when I tap on the menu item.
How do I get the current selected VC?
guard let menuContainerViewController = self.menuContainerViewController else {
return
}
if (self.view.superview! == menuContainerViewController.contentViewControllers[1]) {
print("It is the current VC, do not selectContentViewController")
}
else {
menuContainerViewController.selectContentViewController(menuContainerViewController.contentViewControllers[1])
}
menuContainerViewController.hideSideMenu()
On the main page, you've written that your menu supports "spring animation with params customization". On the same page at the example code, there is no a single word about how to do that. And when I'm looking into the "Sample Code" for more details, I see the very same example code that doesn't clarify spring customization.
I've looked into your source code and tried to do it in the same way, but it doesn't work because 'SpringParams' initializer is inaccessible due to 'internal' protection level
.
I'm sorry if I get something wrong or missed something, but please, can you help me to deal with spring animation parameters customization?
As of now it is not possible to subclass from UITableViewController for the MenuViewController. For example I've written the following class:
class MyMenuViewController: UITableViewController {
// some logic
}
Now I would like to use this framework. The README states I just need to make MyMenuViewController
a subclass of MenuViewController
which doesn't work though as I need to subclass UITableViewController
and MenuViewController
is just a UIViewController
subclass.
Hello i have one tabbar and navigation bar for each item inside tabbar.
var contentList = [MenuItemContentViewController]()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tabbarVC = storyboard.instantiateViewController(withIdentifier: "TabBarViewController") as! TabBarViewController
contentList.append(tabbarVC as MenuItemContentViewController)
I am trying to add tabbar but it gives me an error. Do you know how can i use with tabbar ?
I wondered if there is an approach to using the side menu in which I dont need to create an array of viewControllers straight away?
Its becoming an issue with the nature of my app to have an array of initialised viewControllers stored for the menu, rather than the approach ive seen elsewhere where the controllers are created on tap on the side menu cell via a switch statement on the item.
Any advice on this?
When installing pod I get the error "Unable to find a specification for InteractiveSlideMenu"
My ViewController that uses InteractiveSideMenue dissappears with a sinkhole animation to the ground. I didn't touch the code and installed v2.0. I tried some fixing in viewWillTransitionToSize but without success. Is it a known swift 4 issue?
My specs:
Xcode 9
iphone 7
iOS 11.0.1
Hi,
I have 5 pages inside side menu..
One of that is HomePage.
My flow is like this.
HomePage (tableview) >> CategoryPage
Now From this category page when click button for showmenu getting error like bellow
Could not cast value of type 'UINavigationController' (0x2ee9244) to 'InteractiveSideMenu.MenuContainerViewController' (0x544ab0).
Kindly provide solution for this.
Adding Navigation Controller As menu item do not show menu, i have three controller embedded in respective navigation controller as root view and i have added menu as bar button item, showSideMenu() method is being called but menu is not shown.
I wondered if there was the ability to add the custom row selection as seen in your demo gif on the home page? I wanted a colour block or something to indicate the currently visible viewController in the side menu. Not sure if this is a feature of the api or if this is handled in the tableview delegate methods?
i want to use navigationviewcontroller on my one of view controller instantiate from your api but i getting this error.
Could not cast value of type 'Mosyo.EntriesController' to 'UINavigationController'
let nav = segue.destination as! UINavigationController
let productListController = nav.topViewController as! EntriesController
let cell = sender as! UICollectionViewCell
let indexPath = self.collectionView!.indexPath(for: cell)
how can i fix this ?
thanks.
Possible to disable rotation on all the sub pages except 1?
I've tried many of the solutions on SO, for NavBar UI, but they don't seem to work with this.
Thanks,
Dave
In your animation, it shows the content from an itemViewController when the menu is open. In your Sample app and in my implementation the content disappears and you can only see a blank white view controller off to the side. I'm probably missing something simple to maintain the itemViewController content after it animates to the right.
Edit: That was a worded poorly haha When we're looking at the Cat photo on the Sample App and we open the menu....why does the cat photo disappear? Is it possible to keep the cat photo when the menu is open?
What's the point in setting the property contentViewControllers
? I don't see where it is being used in your code โ I don't need a list of all content view controllers for my app, therefore I'm curious: What's the reason for including it and is it really needed as stated in the README? Couldn't we simplify this library a bit by removing it?
I am trying to open the Side Menu by clicking a button, but the menu isn't opening . I am using the showSideMenu() function, and also have the SideMenuItemContent Delegate present ,but the side view isn't coming .
Hello guys, first off very nice library!
If we embed UINavigationController
as child view to MenuContainerViewController
on iOS11, there is an issue with UINavigationBar
height, when closing the side menu. When interaction starts, UINavigationBar
will resize itself from the top to the size that will be 20pt less then the size of child view, so you will be able to see the view behind.
This can be only seen on iOS11. I tried various stuff to fix it but without much success. If we hide navigation bar, or if the status bar is hidden, the issue will disappear.
I'm also attaching a project so that you can check it out.
Please add NavigationViewController support.
Hi!
I have a lateral menu on the left side of my screen. Right now, when I tap the menu button, the lateral menu comes from the left side and pushes my current view to the right.
I was wondering if it's possible to have the lateral menu covers my current view instead of pushing to the right. Also, if it isn't, is there any workaround that I can do to achieve that?
Thanks a lot!
And thanks for this great library too!
Is there a simple method to change the menu to come from screen right rather than screen left?
I need it to be inverted to the default method
Cheers
I need to show the menu only by clicking on the showMenuButton. Currently the user also can swipe and the menu will appear. How can i disable this functionality?
In SideMenuItemContent
added this code:
func openMenu() {
showSideMenu()
}
and:
menuButton.addTarget(self, action: #selector(openMenu), for: .touchUpInside)
But when I click the button there is no response.
Really, again when starting to use this library in my app I can't see why I need to conform to the SideMenuItemContent
protocol im my view controllers? Is it only a hint so people don't forget they have to call showSideMenu()
somewhere? Cause I can't find how view controllers that conform to that protocol are used within this library ... if it's only a reminder, why not solve it via docs?
I mean you could simplify the library and the docs again by simply saying: If you want to show the side bar, simply call showSideMenu()
. The one thing that would really help would be some kind of helper which allows access to the method from everywhere like the following (which is actually a helper I have written so I don't have to mess with all the stuff in different files but use one file with a quite understandable API instead):
import UIKit
import InteractiveSideMenu
class MenuHelper {
// MARK: - Stored Type Properties
static let shared = MenuHelper()
// MARK: - Stored Instance Properties
let menuViewCtrl = MenuContainerViewController()
// MARK: - Instance Methods
func setMenuViewController(_ menuViewController: MenuViewController) {
menuViewCtrl.menuViewController = menuViewController
}
func showContentViewController(_ contentViewController: UIViewController) {
menuViewCtrl.selectContentViewController(contentViewController)
}
func openMenu() {
menuViewCtrl.showSideMenu()
}
func closeMenu() {
menuViewCtrl.hideSideMenu()
}
}
Hello
My home viewcontroller has tab bar when I try to push any viewcontroller from side menu then tab bar is getting hidden or not able to see.
I am new to swift and just for practice I am tried to implement this.
here you can find my repository if you want to know what I have done.
Thank you in advance.
Hi,
I want to change root view controller when any item selected in another view controller.
Please help me.
Thanks.
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.