I have implemented the slide menu it has a close button but the close button goes under the navigation bar. How it brings it above the navigation bar and slide as menu slider.
Here is how I want the close button.
Try this :
let window = UIApplication.sharedApplication().keyWindow!
window.addSubview(menuView)
window?.bringSubview(toFront: menuView)
Related
I have 2 UIViewControllers. VC1 i embedded into a Navigation controller. I clicked and dragged a UIBarButtonItem to the top right of this VC. I set this button to segue to VC2.
When I try to click and drag a UIBarButton Itemt into VC2 it will not stay in the top right corner. i snaps to the bottom left corner. I know I can do it programatically using self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(handleDone)) ButI want to know why I can't do it in storyboard? as I prefer using it.
It's not a trivial gesture, but you can do it. The problem is that you are dropping the bar button item in the wrong place. Make sure you are hovering the bar button item over the right side of the navigation bar until it "lights up", as shown below:
I need to animate left bar button moving to right side of menu list view in slide bar menu view controller
How can i animate this in swift3.
UIView.animate(withDuration: 0.3, animations: { (Void)
}, completion:nil)
Simple Answer:
You can use a Cloaking in your code
1.create a BarButton on the window the appearance is the same as your left bar button on your viewController, and hide the left bar button on your viewController.
2.animate the BarButton which on the window to your ' right side of menu list view in slide bar menu view controller'.
3.on your slide bar menu view controller create a BarButton the same as your barButton, and remove the BarButton which on the window.
so it will realize your idea.
I have a ViewController that contains a navigation bar. In this navigation bar, there are 2 UIBarButtonItem: A and B.
When A is pressed, another ViewController is displayed as a PopOver (segue present as popover).
If I press anywhere on the screen, the popover is dismissed.
The problem is that if I press on B (the other UIBarButtonItem) the PopOver is not dismissed...
What should I do to automatically dismiss opened popovers when bar buttons from the navigation bar are pressed?
My view controller have a back button show on navigation bar(in a UINavigationController). There is a "edit" mode in current view. When into "edit" mode, I replace the leftBarButtonItem to a "Cancel" button, when exit the "edit" mode, I want to change the left button to "back button" again, how can I do it?
I try self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem, it just remove the "Cancel" button, but not get the "back button" back.
Now I can create a new navigation item with the UI just like the back button, and set it to as leftBarButtonItem, but the position is not same with the native back bar button, and lost the swipe back gesture.
Is there any way to get the native back bar button item back on the navigation bar?
When you leave edit mode, just set:
self.navigationItem.leftBarButtonItem = nil;
In same view controller just add self.navigationItem.backBarButtonItem.title = #"Cancel"; in viewWillAppear.
And add self.navigationItem.backBarButtonItem.title = #"Back"; in your viewDidDisappear to set back button text of your class file .m.
To set Cancel :
- (void)viewWillAppear:(BOOL)animated
{
self.navigationItem.backBarButtonItem.title = #"Cancel";
}
To set Back :
-(void)viewDidDisappear:(BOOL)animated
{
self.navigationItem.backBarButtonItem.title = #"Back";
}
I am using JASidePanels in iOS and trying to get the menu button to show on the right instead of the left (center panel is a UINavigationController so the left menu button gets replaced with the back button text) but I cannot seem to get the right button to show regardless of what I try.
I tried setting only a right panel (no left panel). Is there a way within JASidePanels to move the menu button from the left side of the navigation bar to the right side?
thanks
Add a new bar button to the navigation bar within your viewDidLoad method:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Right"
style:UIBarButtonItemStylePlain
target:self
action:#selector(toggleRightPanel)];
and method to be called by right bar button:
- (void)toggleRightPanel {
[[self.parentViewController valueForKey:#"sidePanelController"] performSelector:#selector(toggleRightPanel:)];
}