Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added dynamic tabBarCell height

  • Loading branch information...
commit 1941e20201c335d45112629d508cdcce5d9836a6 1 parent 98efd08
@kflip kflip authored
View
5 NGVerticalTabBarController/NGVerticalTabBarController.h
@@ -6,8 +6,9 @@
// Copyright (c) 2012 NOUS Wissensmanagement GmbH. All rights reserved.
//
-@protocol NGVerticalTabBarControllerDelegate;
-@class NGVerticalTabBar;
+#import "NGVerticalTabBarControllerDelegate.h"
+#import "NGVerticalTabBar.h"
+
/** NGVerticalTabBarController is a vertical TabBar displayed on the left side of the device */
@interface NGVerticalTabBarController : UIViewController
View
17 NGVerticalTabBarController/NGVerticalTabBarController.m
@@ -5,7 +5,7 @@
// the default width of the tabBar
#define kNGTabBarControllerDefaultWidth 150.f
-
+#define kNGTabBarCellDefaultHeight 120.f
@interface NGVerticalTabBarController () <UITableViewDataSource, UITableViewDelegate> {
// re-defined as mutable
@@ -14,6 +14,7 @@ @interface NGVerticalTabBarController () <UITableViewDataSource, UITableViewDele
// flags for methods implemented in the delegate
struct {
unsigned int widthOfTabBar:1;
+ unsigned int heightForTabBarCellAtIndex:1;
unsigned int shouldSelectViewController:1;
unsigned int didSelectViewController:1;
} delegateFlags_;
@@ -29,6 +30,7 @@ - (void)updateUI;
- (CGFloat)askDelegateForWidthOfTabBar;
- (BOOL)askDelegateIfWeShouldSelectViewController:(UIViewController *)viewController atIndex:(NSUInteger)index;
- (void)callDelegateDidSelectViewController:(UIViewController *)viewController atIndex:(NSUInteger)index;
+- (CGFloat)askDelegateForHeightOfTabBarCellAtIndex:(NSUInteger)index;
@end
@@ -102,6 +104,7 @@ - (void)setDelegate:(id<NGVerticalTabBarControllerDelegate>)delegate {
// update delegate flags
delegateFlags_.widthOfTabBar = [delegate respondsToSelector:@selector(widthOfTabBarOfVerticalTabBarController:)];
+ delegateFlags_.heightForTabBarCellAtIndex = [delegate respondsToSelector:@selector(heightForTabBarCell:atIndex:)];
delegateFlags_.shouldSelectViewController = [delegate respondsToSelector:@selector(verticalTabBarController:shouldSelectViewController:atIndex:)];
delegateFlags_.didSelectViewController = [delegate respondsToSelector:@selector(verticalTabBarController:didSelectViewController:atIndex:)];
}
@@ -213,6 +216,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
+ return [self askDelegateForHeightOfTabBarCellAtIndex:[indexPath row]];
+}
+
////////////////////////////////////////////////////////////////////////
#pragma mark - Private
////////////////////////////////////////////////////////////////////////
@@ -267,4 +274,12 @@ - (void)callDelegateDidSelectViewController:(UIViewController *)viewController a
}
}
+- (CGFloat)askDelegateForHeightOfTabBarCellAtIndex:(NSUInteger)index {
+ if(delegateFlags_.heightForTabBarCellAtIndex) {
+ return [self.delegate heightForTabBarCell:self atIndex:index];
+ }
+
+ return kNGTabBarCellDefaultHeight;
+}
+
@end
View
3  NGVerticalTabBarController/NGVerticalTabBarControllerDelegate.h
@@ -24,6 +24,9 @@
/** Asks the delegate for the width of the UITableView that acts as the tabBar */
- (CGFloat)widthOfTabBarOfVerticalTabBarController:(NGVerticalTabBarController *)tabBarController;
+/** Asks the delegate fot the specific height of an NGVerticalTabBarCell */
+- (CGFloat)heightForTabBarCell:(NGVerticalTabBarController *)tabBarController atIndex:(NSUInteger)index;
+
/** Asks the delegate whether the specified view controller should be made active. */
- (BOOL)verticalTabBarController:(NGVerticalTabBarController *)tabBarController
shouldSelectViewController:(UIViewController *)viewController
Please sign in to comment.
Something went wrong with that request. Please try again.