Code Monkey home page Code Monkey logo

slideoutnavigation's Introduction

AMSlideOutNavigationController

CocoaPods Build Status Analytics

SlideOut Navigation Controller for iOS. This controller replicates the behaviour of the 'slide-out' navigation of applications like Facebook or Steam. The project currently mimics FB's app styling, you can change all the table colors and options using the Options Dictionary (see documentation below). ARC only.

Part of the code is based off this blog post made by Nick Harris

Screenshot

AMSlideOutNavigationController

Setup with CocoaPods

  • Add pod 'AMSlideOutController' to your Podfile
  • Run pod install
  • Run open App.xcworkspace
  • Import AMSlideOutNavigationController.h in your AppDelegate
  • Init AMSlideOutNavigationController using the data structure as follows.

Init data

The ViewControllers presented by the SlideOut navigation are arranged in sections and rows of a UITableView.

You can use the following helper methods to setup your views:

  • addSectionWithTitle: to add a section
  • addViewControllerToLastSection:tagged:withTitle:andIcon: to add a viewcontroller to the last section
  • addViewControllerToLastSection:tagged:withTitle:andIcon:beforeChange:onCompletion: to add a viewcontroller and call a block before and after the view switch
  • addViewController:tagged:withTitle:andIcon:toSection: to add a viewcontroller to a specific section
  • addViewController:tagged:withTitle:andIcon:toSection:beforeChange:onCompletion: to add a viewcontroller to a specific section and call a block before and after the switch

To create a new section:

// Note: Leave the title blank to hide the section header
[self.slideoutController addSectionWithTitle:@"Section"];

To create a new row:

[self.slideoutController addViewControllerToLastSection:controller		// Your UIViewController
												 tagged:1				// Used to change the object's properties, i.e. the badge
											  withTitle:@"First View"	
												andIcon:@"icon1.png"];	// 44x44 icon held in the project's resources

To create a new row that only calls an action:

[self.slideoutController addActionToLastSection:^{
	// some action
}
										 tagged:3
									  withTitle:@"Action"
										andIcon:@""];

The main data structure is an array of sections. Each section item is a dictionary, containing the section title and an array describing the ViewControllers. Each item of this array is a dictionary containing the title, icon's file name, a numeric tag and the reference to the ViewController. You can also pass the complete data structure to the init method, but it's not recommended. Check out the sample to understand how these methods work.

Options Dictionary

As of version 1.0.0 AMSlideOutNavigationController's configuration can be handled by passing an NSDictionary to it. The default values can be found in AMSlideOutNavigationController.m. Here's a brief description of the possible options:

AMOptionsEnableGesture            // @(BOOL), Enables the pan gesture. Defaults to YES
AMOptionsEnableShadow             // @(BOOL), Enables the shadow under the content's view. Defaults to YES
AMOptionsSetButtonDone            // @(BOOL), Sets the Menu button's state to 'Done' when the tray is open. Defaults to NO
AMOptionsUseBorderedButton        // @(BOOL), Sets the Menu button to have a bordered style. Defaults to NO
AMOptionsButtonIcon               // UIImage, Icon displayed in the Menu button. Defaults to the embedded 'iconSlide.png'
AMOptionsTableBackground          // UIImage, Background image displayed and tiled as the TableView's background. Defaults to nil (solid color)
AMOptionsTableOffestY             // @(float), Y offset for the menu table. Defaults to 20.0f in iOS7, 0.0f in previous versions.
AMOptionsUseDefaultTitles         // @(BOOL), When enabled the content view's title is set as the manu item's text. Defaults to YES
AMOptionsSlideValue               // @(float), The width of the menu. The content's view snaps to this value. Defaults to 270
AMOptionsBackground               // UIColor, Menu's background color. Defaults to the one in the main screenshot of this page
AMOptionsSelectionBackground      // UIColor, Menu background color for the selected item. Defaults to the one in the main screenshot of this page
AMOptionsHeaderFont               // UIFont, Font used in the menu header. Defaults to Helvetica@13
AMOptionsHeaderFontColor          // UIColor, Font color used in the menu header. Defaults to the one in the main screenshot of this page
AMOptionsHeaderShadowColor        // UIColor, Shadow color used in the menu header. Defaults to the one in the main screenshot of this page
AMOptionsHeaderPadding            // @(float), Padding used in the menu header. Defaults to 10
AMOptionsHeaderGradientUp         // UIColor, Menu's gradient starting color. Defaults to the one in the main screenshot of this page
AMOptionsHeaderGradientDown       // UIColor, Menu's gradient ending color. Defaults to the one in the main screenshot of this page
AMOptionsHeaderSeparatorUpper     // UIColor, Color used in the menu header separator. Defaults to the one in the main screenshot of this page
AMOptionsHeaderSeparatorLower     // UIColor, Color used in the menu header separator. Defaults to the one in the main screenshot of this page
AMOptionsCellFont                 // UIFont, Font used in the menu item. Defaults to Helvetica@14
AMOptionsCellFontColor            // UIColor, Font color used in the menu item. Defaults to the one in the main screenshot of this page
AMOptionsCellBadgeFont            // UIFont, Font used in the menu badge. Defaults to Helvetica@12
AMOptionsCellBadgeFontColor       // UIColor, Badge's font color. Defaults to white
AMOptionsCellBadgeBackColor       // UIColor, Badge's background color. Defaults to black
AMOptionsCellBackground           // UIColor, Menu item background color. Defaults to the one in the main screenshot of this page
AMOptionsCellSeparatorUpper       // UIColor, Color used in the menu separator. Defaults to the one in the main screenshot of this page
AMOptionsCellSeparatorLower       // UIColor, Color used in the menu separator. Defaults to the one in the main screenshot of this page
AMOptionsCellShadowColor          // UIColor, Shadow color used in the menu item. Defaults to the one in the main screenshot of this page
AMOptionsImagePadding             // @(float), Padding used in the menu icon. Defaults to 50
AMOptionsImageLeftPadding         // @(float), Left padding used in the menu icon for the image. Defaults to 0
AMOptionsTextPadding              // @(float), Padding used in the menu item. Defaults to 20
AMOptionsBadgePosition            // @(float), Badge's left offset. Defaults to 220
AMOptionsHeaderHeight             // @(float), Menu header's height. Defaults to 22
AMOptionsImageHeight              // @(float), Menu icon's height. Max value is currently 44 pixels. Defaults to 44
AMOptionsImageOffsetByY           // @(float), Menu icon's offset from the top. Defaults to 0
AMOptionsAnimationShrink          // @(BOOL), Enables the Shrink animation. Defaults to @YES
AMOptionsAnimationShrinkValue     // @(float), The amount of scaling for the shrink animation. Defauults to @0.3
AMOptionsAnimationDarken          // @(BOOL), Enables the fadout animation. Defaults to @YES
AMOptionsAnimationDarkenValue     // @(float), The darker alpha value of the dark overlay. Defaults to @0.7
AMOptionsAnimationDarkenColor     // UIColor, The base color of the fadout animation. Defaults to [UIColor blackColor]
AMOptionsAnimationSlide           // @(BOOL), Enables the slide animation of the menu to the side. Defaults to @NO
AMOptionsAnimationSlidePercentage // @(float), Value from 0 to 1. Determines how much the table should slide aside
AMOptionsTableHeaderClass         // NSString, The class name of your custom header. Defaults to AMSlideTableHeader
AMOptionsDisableMenuScroll        // @(BOOL), Prevents the menu scrolling if its content's height is less than the view's height. Defaults to @NO
AMOptionsTableCellClass           // NSString, The class name of your custom cell. It must inherit from AMSlideTableCell. Defaults to AMSlideTableCell
AMOptionsTableCellHeight          // @(float), The default cell's height. Defaults to @44
AMOptionsTableIconMaxSize         // @(float), the default menu item's icon. Defaults to @44
AMOptionsSlideoutTime             // @(float), The default duration of the open/close animation. Defaults to @0.15
AMOptionsTableBadgeHeight         // @(float), The table badge height. Defaults to @20 
AMOptionsSlideShadowOffset        // @(float), The shadow's offset under the content controller. Defaults to -6
AMOptionsSlideShadowOpacity       // @(float), The shadow's opacity under the content controller. Defaults to 0.4
AMOptionsBadgeShowTotal           // @(BOOL=), Enables the automatic global badge. Defaults to @NO
AMOptionsBadgeGlobalFont          // @(UIFont), The global badge's font. Defaults to [UIFont systemFontOfSize:8]
AMOptionsBadgeGlobalPositionX     // @(float), The global bages's X position (relative to the bar button). Defaults to @20
AMOptionsBadgeGlobalPositionY     // @(float), The global bages's Y position (relative to the bar button). Defaults to @(-5)
AMOptionsBadgeGlobalPositionW     // @(float), The global bages's width. Defaults to @16
AMOptionsBadgeGlobalPositionH     // @(float), The global bages's height. Defaults to @16
AMOptionsBadgeGlobalTextColor     // @(UIColor), The glboal badge's text color. Defaults to white
AMOptionsBadgeGlobalBackColor     // @(UIColor), The glboal badge's background color. Defaults to red
AMOptionsBadgeGlobalShadowColor   // @(UIColor), The glboal badge's text shadow color. Defaults to a clear color
AMOptionsNavbarTranslucent        // @(BOOL), The navbar translucent state. Defaults to @NO
AMOptionsContentInsetTop          // @(float), The top content inset of the table view. Defaults to @0

sample usage:

self.slideoutController = [AMSlideOutNavigationController slideOutNavigation];

[self.slideoutController setSlideoutOptions:@{
						   AMOptionsEnableShadow : @(NO),
					       AMOptionsHeaderFont : [UIFont systemFontOfSize:14]
 }];

Further customization

To customize the appearance of your navigation bar you can use the system's UIAppearance class, i.e.:

// Navbar customization
[[UINavigationBar appearance] setTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationBar.png"] forBarMetrics:UIBarMetricsDefault];
    
// Navbar font customization
NSDictionary *attributes = @{UITextAttributeFont: [UIFont fontWithName:@"Copperplate" size:14]};
NSDictionary *titleAttributes = @{UITextAttributeFont: [UIFont fontWithName:@"Copperplate" size:20]};
[[UIBarButtonItem appearance] setTitleTextAttributes: attributes
											forState: UIControlStateNormal];
[[UINavigationBar appearance] setTitleTextAttributes: titleAttributes];

// Back button customization
UIImage *barButton = [[UIImage imageNamed:@"button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(-2,5,0,6)];
[[UIBarButtonItem appearance] setBackgroundImage:barButton forState:UIControlStateNormal
									  barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:4 forBarMetrics:UIBarMetricsDefault];

Using UIAppearance and the options' dictionary you can easily achieve a view similiar to the second screenshot in this page.

Sample

self.slideoutController = [AMSlideOutNavigationController slideOutNavigation];

// Add a first section
[self.slideoutController addSectionWithTitle:@"Section One"];

// Add two viewcontrollers to the first section
controller = [[UIViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
[self.slideoutController addViewControllerToLastSection:controller tagged:1 withTitle:@"First View" andIcon:@"icon1.png"];

controller = [[UIViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self.slideoutController addViewControllerToLastSection:controller tagged:2 withTitle:@"Second View" andIcon:@"icon2.png"];

// Add a second section
[self.slideoutController addSectionWithTitle:@"Section Two"];

// Add two viewcontrollers to the second section
controller = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
[self.slideoutController addViewControllerToLastSection:controller
												 tagged:3
											  withTitle:@"First View"
												andIcon:@"icon1.png"
										   beforeChange:^{
											   NSLog(@"Changing viewController");
										   } onCompletion:^{
											   NSLog(@"Done");
										   }];

controller = [[UIViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self.slideoutController addViewControllerToLastSection:controller tagged:4 withTitle:@"Second View" andIcon:@"icon2.png"];

[self.window setRootViewController:self.slideoutController];

Storyboard

If you use Storyboard you can easily integrate AMSlideOutNavigationController within your AppDelegate.

Just set a Storyboard ID for each of your ViewController that will become a root element of the navigation tree:

SlideOutNavigationStoryboard

then instantiate your ViewControllers in your AppDelegate like this:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

UIViewController* controller;

self.slideoutController = [AMSlideOutNavigationController slideOutNavigation];

[self.slideoutController addSectionWithTitle:@""];

controller = [storyboard instantiateViewControllerWithIdentifier:@"FirstController"];
[self.slideoutController addViewControllerToLastSection:controller tagged:1 withTitle:@"First View" andIcon:@""];

controller = [storyboard instantiateViewControllerWithIdentifier:@"SecondController"];
[self.slideoutController addViewControllerToLastSection:controller tagged:2 withTitle:@"Second View" andIcon:@""];

[self.window setRootViewController:self.slideoutController];

Sections

1.6+: Pass a nil value as the section name if you don't want the section header visible. You can specify a custom header class and height for each section, this will give you the opportunity to add a separator that looks different from an header. You can also define a global custom header class. Your custom class must be a subclass of AMSlideTableHeader. Pre 1.6: Leave the section name blank if you don't want the section header visible.

Badges

Set the badge value (NSString) via the method setBadgeValue:forTag:. This sets the badge value of the row with the numeric tag provided during the views' setup. If AMOptionsBadgeShowTotal is enabled, a global badge will be displayed on the left bar button.

[self.slideoutController setBadgeValue:@"10" forTag:3];

You can se a custom global badge by using:

[self.slideoutController setBadgeTotalValue:@"10"];

Icons

The icon must be 44x44. Blank icon name will result in a row with only text, with different indentation.

Changelog

v1.8

  • Added lazy instantiation of view controllers. Thanks to mixalich7b

v1.7.5

  • Added global badge on the tray button.

v1.7

  • Added accessibility support. (Thanks to Michael James)
  • Added ability to use custom cells for the menu items.

v1.6

  • Added slide animation to the menu.
  • Changed header configuration.
  • Added option to use a custom default header view.
  • Added option to use a custom headers view for each section header.
  • Added setMenuScrollingEnabled methos

v1.5

  • Added shrink and fadeout animations to the menu drawer.

v1.4

  • Added the ability to use either a string with the image name or the UIImage itself for the controller's icon.

v1.3

  • Added rotation support
  • Minor bugfixes

v1.2

Added a method to programmatically switch controller and perform an action afterwards

- (void)switchToControllerTagged:(int)tag andPerformSelector:(SEL)selector withObject:(id)obj

Using this library?

Please let me know! I'll be glad to link your project here.

MIT License

Copyright (c) 2013 Andrea Mazzini. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

slideoutnavigation's People

Contributors

achitre avatar andreamazz avatar anishb avatar chrux avatar donaciano avatar drallgood avatar hariprasad avatar iesta avatar jackman0 avatar jlwebster avatar mixalich7b avatar readmecritic avatar russellwpatterson avatar thesooth avatar umjames avatar waffle-with-pears avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slideoutnavigation's Issues

Doesn't work under XCode 5, but iOS 6.* simulator

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString sizeWithAttributes:]: unrecognized selector sent to instance 0x9c74440'
*** First throw call stack:
(0x2f42012 0x2d67e7e 0x2fcd4bd 0x2f31bbc 0x2f3194e 0x280dd0 0x2799fa 0x1b838fb 0x1b839cf 0x1b6c1bb 0x1b6a872 0x1b755d4 0x1b781c4 0x1b78546 0x278d5e 0xaaad 0x1baa1c7 0x1baa232 0x1bb5c25 0x1db53a3 0x1bb2ee3 0x1bb3167 0x1bb31a7 0x2164dd 0x979a6 0x9876a 0x26385e 0x2644b1 0x365653f 0x3668014 0x36587d5 0x2ee8af5 0x2ee7f44 0x2ee7e1b 0x3b627e3 0x3b62668 0x1ac8ffc 0x257d 0x24e5 0x1)
libc++abi.dylib: terminate called throwing an exception

Because following code is wrong (__IPHONE_7_0 is defined, but it doesn't mean that iOS7 is used!)

ifdef __IPHONE_7_0

    CGSize fontSize = [text sizeWithAttributes: @{NSFontAttributeName: self.options[AMOptionsCellBadgeFont]}];

else

    CGSize fontSize = [text sizeWithFont:self.options[AMOptionsCellBadgeFont]];

endif

Programmatically pop slidenavigation controller?

I'm using some startup view controller and your sliding controller as second screen. To avoid double navigation bar, i'm hiding original bar, with Back button and use sliding navigation bar menu instead. But i need to have possibility to return back to original (start) controller from some inner contentview controller.

How to do it?

Side button catches click on large piece of area

Steps to reproduce:

  1. Run SlideoutStroryboardSample
  2. Try to click on rectange area marked as red (see screenshot)

Actual: clicking far from Side button on UINavigationBar fires action, even though clicking on View area which doesn't know about button will fire click action too.
Expected: ~ only yellow area should accept clicks

SideButtonBug

slideout looks grey in ios7

is there anyfix where slidout looks the same in ios 6 and ios 7
in ios6 it looks blue whereas in ios 7 it is grey

Weird crash in AMSlideTableCell in iOS 7

Hi.
I've gotten a few weird crash reports from a user that seem to indicate a crash in AMSlideTableCell.m line 33.
Looks like the options array is garbage/missing (NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds).
Any idea what that might be?
iOS 7 issue?

Translucent navigation bar in iOS 7

Due to new behavior iOS 7 the following line AMSlideoutNavigationController.m adds extra padding.

self.contentController.navigationBar.translucent = YES;

/*
New behavior on iOS 7.
Default is YES.
You may force an opaque background by setting the property to NO.
If the navigation bar has a custom background image, the default is inferred
from the alpha values of the imageβ€”YES if it has any pixel with alpha < 1.0
If you send setTranslucent:YES to a bar with an opaque custom background image
it will apply a system opacity less than 1.0 to the image.
If you send setTranslucent:NO to a bar with a translucent custom background image
it will provide an opaque background for the image using the bar's barTintColor if defined, or black
for UIBarStyleBlack or white for UIBarStyleDefault if barTintColor is nil.
*/

Proposed Enhancements

Hi @andreamazz!
Thanks for simple and amazing framework.

I want to propose such enhancements:
1.Add property to specify navigation bar style (currently it's blue by default) or more configurable (I see tranding apps don't use default Apple gloss in navigation bar)
2.Set navigation bar title by default with selected cell title from table view:

[self.slideoutController addViewControllerToLastSection:controller
      tagged:1
      withTitle:@"First View" // this title is used for cell and in navigation bar title (currently it's empty)
       andIcon:@"icon1.png"];  

3.Remove code that sets barButton to UIBarButtonItemStyleDone. IMHO: it looks not bad for default blue style but with other cases (black or probably red) it looks ugly. Path, Facebook and others don't emphasize the status of this button.
4.Adjust kSlideValue according to this UI recomendations. I've tried ~270 and it looks good (not sure because code at home πŸ˜„ )
687474703a2f2f7777772e65666c617467616d65732e636f6d2f6769746875622f414d536c6964654f7574313530382e706e67

Customize table view cells

Hi, andreamazz

I want to add some customized cell , how to do it? It will change back to default style, even though I return my customized cell on my AMSlideOutNavigationController instance .

iAd integration

Is it possible in this code to send a message to one of the view controllers that it should stop displaying iAds before it is slid aside, and that it can start displaying them again when it is slid back?

Adding Right Bar Button

Hi,
Is it possible to add second bar button to the right side.Using Push or Modal to open another ViewController.Example Search button.
Thank you

Jumping on transition

I've been loading my slideOutNavigation class after the user passes a login prompt. I replace the rootviewcontroller inside a UIView transitionWithView animation block.

Works well except the navigation bar at the top drops 20 points immediately after the transition completes, only on iOS 7.0.

From my digging around it seems right now that most likely I'm facing the same issue described here: http://stackoverflow.com/questions/14795645/uinavigationbar-jumps-20pixels-during-transitionfromviewcontroller

I have attempted the suggested resolution (it didn't work) but maybe I did it wrong. I can't get a handle on how SlideOutNav is using the navigation bar.

Specifically I don't understand the following: (AMSlideOutNavigationController.h)
@Property (nonatomic, assign) Class navigationBarClass;

and also in the corresponding .m file
self.contentController = [[self.navigationControllerClass alloc] initWithNavigationBarClass:self.navigationBarClass toolbarClass:self.navigationToolbarClass];

It looks to me like maybe AMSlideOutNavigationController is subclassing uinavigationbar in an indirect way. The superclass is UIViewController, and no UINavigationBarDelegate protocol is being declared, so perhaps this is a trick to get around single-inheritance?

I tried adding - (BOOL)wantsFullScreenLayout but there was no change.

Any suggestions?

Action isn't added to specified section but to the last one

There's a bug in AMSlideOutNavigationController.m in line 106:
The method call isn't forwarded to addViewController:tagged:withTitle:andIcon:toSection:beforeChange:onCompletition: but to addViewControllerToLastSection:tagged:withTitle:andIcon:beforeChange:

AMOptionsCellBackground and clearColor

I may be doing something wrong but i think the AMOptionsCellBackground option with clearColor to get transparent cells does not work anymore. I have a white background.
Maybe the cells are set to "opaque".
Thank you

options for insetY

I don't know if this is something useful or maybe there is another already done way to get it, but i saw when i add the tableview to the navigation controller, there is the offsetY 20 pixels, but when you scroll up you see how the tableview "cuts" in those 20 pixels, so i changed it to 0 and added this to the code:

self.tableView.contentInset = UIEdgeInsetsMake(20, 0, 0, 0);

so now when i scroll up i see the table cell behind the status bar info and not cut.

it would be great to add that functionality as an option or id there is a "correct" way to do this behavior with the current version of this class please tell me :D

thanks for sharing this amazing work.

Disable AMOptionsEnableGesture just in one view

Hi, I was wondering if it was possible to disable AMOptionsEnableGesture just in one view?

The issue is that UIPanGestureRecognizer interferes with swipe to delete on a UITableViewController. Basically swipe to delete no longer works.

Or perhaps you know a workaround so that AMOptionsEnableGesture works with swipe to delete on a UITableViewController.

AMOptionsUseBorderedButton behaves differently

I want a bar button with UIBarButtonItemStylePlain style. According to these lines, it is possible by setting AMOptionsUseBorderedButton to @(YES)

if ([self.options[AMOptionsUseBorderedButton] boolValue]) {
    self.barButton = [[UIBarButtonItem alloc] initWithImage:self.options[AMOptionsButtonIcon]
                                                      style:UIBarButtonItemStylePlain
                                                     target:self
                                                     action:@selector(toggleMenu)];

    accessibilityObject = self.barButton;

}

However, there is also UIBarButtonItemStyleBordered style that actually conflicts with the term.

Can't disable gesture recognizer

Hi @andreamazz

I see that swipe gesture can't be disabled (for example I want to show side view only by button click)

Example of usecase:

  1. Open your SlideOutSample (not storyboard).
  2. Select 'Second View' from 'First Section'
  3. Click on the latest button - 'Set badge for Second View, Second Section' which loads child view

On this child view you can show side view by swiping on UINavigationBar or entire view.

In some cases I want to disable.

Badge is not displayed?

Just added [self.slideoutController setBadgeValue:@"1" forTag:2];
to the AMAppDelegate within SlideoutStoryboardSample, but doesn't see any badge text.

How to remove the status bar (in IOS7) ?

I added this to the end of AMSlideOutNavigationController.m :

  - (BOOL)prefersStatusBarHidden  {  return YES; }

That removes the status bar in the children views but not in the slideout menu.

Do you know a way to remove it everywhere ?

The menu icon should have a bigger hit area, and be touchable in the corner

Hello,

I'm using this framework and have noticed a lot of users miss the icon because they try to touch it in the upper left corner. So they touch a few times and finally manage to target it on the third try. This feels like a usability fail.

This is actually a well-known user interface / usability phenomenon also known as Fitts' Law; that people tend to navigate on screens and user interfaces relative to corners and edges of the screen. This is for example why you can open the apple menu by clicking in the upper left corner of your screen. Also, the back button in all iOS applications is reachable by clicking in the corner.

Sorry if that motivation is a bit too long. :)

I've been looking into how to extend the hit rect while keeping the menu icon intact. Maybe by changing the padding of the containerview for this icon somehow? Any ideas?

Thanks for a great framework!

Separator lines between menu entries

I didn't find a way to add separator lines between menu entries, I think it would be a nice feature to have for the clarity of the menu. I'm aware of the sections feature, but I don't need to display a text between my groups of entries.

Some new settings would be needed such as :

  • AMOptionsSeparatorLineWidth: @(float), Width of the separator lines in percent. Defaults to 90
  • AMOptionsSeparatorLineHeight: @(float), Height of the separator lines in pixels. Defaults to 1
  • AMOptionsSeparatorLineColor: UIColor, Color of the separator lines. Defaults to [UIColor whiteColor]
  • AMOptionsSeparatorLinePadding: @(float), Amount of vertical padding for the separator lines in pixels. Defaults to 0

Lower performance

Hi, do you notice that UI becames less flud when inserted in this controller on iPhone4?
I don't know yet if this is specific to my app. I have a couple of table view controllers, controller by the sldeout nav controller and I notice that iPhone has hard times when doing animations. This is not present on iPad and also emulator works just fine

Landscape mode doesn't work in iOS 5.1

I added this method in AMSlideOutNavigationController.m to make it work :

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

Table won't scroll past certain point

For testing purposes, I've added 30 elements to the first section (which is usually filled with the users data => might vary in size) and 2 to a second one.

Now I can't scroll all the way down to the second section.

Any idea why this is happening?

Shifted Row

I have this code in AppDelegate:

    self.rootNavController = self.slideoutController.contentController; 
    self.rootNavController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

It works. Then I have the following view configuration:
0: Table View (highly customized). No problem with that
1: Conventional static UIView. No problem also here
2: Just a standard Table View with a couple of rows. Here is an issue. When you switch between this view and other view, every time you turn back here, you notice your table is shifted down by the offset = top bar height (I suppose). If the nav bar is not transcluent, this problem is not present.

I think there is something with arithmetics, because when the bar is transcluent, the content goes also under it

Remove/Clear menu items for a section

Up until your commit today, it was possible to directly manipulate the menuItems array and remove certain entries or clear them out entirely.

Do you think it would be possible to get this functionality back somehow?

I was using it to dynamically add controllers based on data I get from a server.

Slide animation

Hi,
Great control :-)
Would it be easy to add a slide animation for the menu ?
Thank you !

18 pixels missing

Hello,

When i run the menu in landscape mode i get this:

http://cl.ly/image/0f2V3R0y3W0U

but if in that same run i change the orientation it gets fixed, this only happens when i run the app in landscape, if i run it the first time in portrait, it shows the correct size of the table.

Thanks

Improper view controller containment

This class is not using the view controller containment methods introduced in iOS 5. As such, this class will not handle certain things properly, one of them being rotation.

Option to disable scrolling in the menu

For menus that are small enough to be entirely displayed on the screen it would be nice to have an option to disable scrolling when dragging them, else they are bouncing.

Could be by default, probably best since it doesn't make sense to be able to bounce in this case, or with an option :

  • AMOptionsMenuScrolling // @(BOOL), Enables scrolling for the menu. Defaults to @yES

- (UIViewController *)popViewControllerAnimated:(BOOL)animated doesn't work?

Because I want a very customized back button, I've hidden the default button and replaced it with an overriden leftbutton. Thus, I'm left to code the navigation 'back' function manually. I followed this article: http://beageek.biz/how-to-add-custom-code-navigation-controller-back-button-xcode-ios/

The question is that when I try to pop the view controller, using the navigation controller in the AMSlideOut, the view doesn't change. I'm guessing that this is a side effect of the root view being the AMSlideOut and not directly a UINavigationController. Is this true?

From reading the code, - (void)loadView appears responsible for updating the contentViewController (which, in reality, is the navigation controller), but when I call it, I get a dark/lack screen.

Here is my code:

-(void)back{
    NSLog(@"You touched me!");
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [delegate.slideoutController.navigationController popViewControllerAnimated:TRUE];
    [delegate.slideoutController loadView];
}

The expected behavior, if I were working with a navigation controller directly, is that the present view controller would be dismissed. To test this, I used this code, slightly modified, in a new 'Master-Detail Application':

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Detail", @"Detail");
        UIImage *back_img = [UIImage imageWithPDFNamed:@"navigation_back.pdf" atHeight:40];

        UIButton *back_view = [UIButton buttonWithType:UIButtonTypeCustom];
        [back_view setFrame:CGRectMake(0,0, 40, 40)];
        [back_view setBackgroundImage:back_img forState:UIControlStateNormal];
        [back_view addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];

        UIBarButtonItem *back_btn = [[UIBarButtonItem alloc]initWithCustomView:back_view];
        self.navigationItem.hidesBackButton = YES;
        self.navigationItem.leftBarButtonItem = back_btn;
    }
    return self;
}
-(void)back{
    NSLog(@"You touched me!");
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [delegate.navigationController popViewControllerAnimated:TRUE];
}

The result was as expected. The last view controller was popped from the stack and I was navigated back to the previous view.

I am willing to implement the code to make this behavior available, but I am uncertain which direction you'd like to take. I would propose making AMSlideOut an overridden UINavigationController instead of a UIViewController and implement the appropriate methods, interacting directly with the navigation stack. I've never done so, so it may be easier for someone else, even yourself.

Item in section without view

@andreamazz I have another new idea πŸ˜„

What about adding item just for some action without loading any view.
For example:

[self.slideoutController addItemToSection:1
    withTitle:@"Item just with action"
      andIcon:@"icon1.png"
    andAction:^{
        UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Some action"
                                                         message:@"Some message." 
                                                        delegate:nil 
                                               cancelButtonTitle:@"OK"
                                               otherButtonTitles:nil] show];
}];

Unexpected effects for swiped view

Hi @andreamazz again πŸ˜„

I've caught very interesting issue.

I've created a simple project based on one of your examples. You can download it here

Description of example
1.Settings can be shown only by clicking on button:

[self.slideoutController setSlideoutOptions:@{AMOptionsEnableGesture : @(NO)}];

2.There is 'First View' that has UITableView and 'Child' bar button to push similar view. As swipe gesture is disabled you can't open settings from 'Child View'.

If you look at my video on youtube you can see that during some panic clicking it's possible to have loaded 'Child View' in slided out view. Maybe it sounds not clear but hope video will explains better.

After that this slided out view can catch events and you can return to parent view and make some actions on it.

As I see AMSlideOutNavigationController during showing side menu just move content for some value and put transparent view on it. (Correct me if I'm wrong)

  1. First of all what can you say about this video?
  2. What about not moving view but making screenshot and moving screenshot to avoid such side effects when slided out view can catch events?

Gestures handling interferes with gestures in content

I've implemented a custom slider.
When using it standalone it works fine, but when I try to use it in a subview of AMSlideOutNavigationController it reacts choppy. This happens even if I've disabled the gestures for the navigation controller.
This is (probably) due to the fact that disabling the gestures doesn't actually do very much. The gesture handlers are still registered, they just aren't handling the gestures anymore.

How about add more extendent options for animation?

Hi, Andreamaz

Thanks for your quick feedback at last time.

Now I want to adjust the animateWithDuration(default is 0.15) setting for slide animation in my instance class.
But it is difficult.

How about to make the default setting more extendent in SlideOutNavigation?

iPad screens stretched past bounds

Works perfectly on iPhone, but on iPad the views are stretched past the viewable bounds. See attached screen shot.

This is true for all of the views added to the slideoutnavigation controller. They are also all table view controllers if that makes any difference.

iOS-Simulator-Screen-shot-2013-02-20-11 17

Manipulating Navigation "on the fly"

Hi,
this is not really an Issue, more a question :)

Is it possible to manipulate the navigation "on the fly"?
For example, adding menu items after a login procedure?

Thanks :)

Serious performance issue

Hi @andreamazz
SlideOutNavigation has serious performance issue.

I've modified your StroryboardExample project:

  • added FirstViewController for the first view
  • put UITableView
  • implemented required delegates, datasource

You can download it from my dropbox folder here.

Steps to reproduce:

  1. Download project and run it.
  2. Scroll through table with slow speed that should still scroll ~2-3 row after you release finger/mouse pointer.

Actual: It works very slow on iPhone 4 and iPhone 4s with ugly lags. You can't see them on iPhone 5 but seems like because it has better hardware.
You can see them also in simulator on video I've prepared here.
Expected: No lags, no performance issue.

Programatically navigating to a view controller does not work.

Is there a way to programmatically navigate to a view controller? I've tried:

[slideoutController setCurrentViewController:myViewController];

and also:

[[slideoutController navigationController] popToViewController:myViewController animated:YES];

Neither seem to work.

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.