From f3fc52d26f6601b8c4ac64a5bd508fcc857e88f8 Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Mon, 25 Jun 2012 15:19:49 -0700 Subject: [PATCH 01/10] Added a UIPageControl --- Classes/ViewController.m | 4 +-- InfiniTabBar.h | 9 +++++- InfiniTabBar.m | 61 +++++++++++++++++++++++++++++----------- 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/Classes/ViewController.m b/Classes/ViewController.m index 7a07021..20eda7d 100644 --- a/Classes/ViewController.m +++ b/Classes/ViewController.m @@ -55,7 +55,7 @@ - (void)viewDidLoad { [mostViewed release]; // Don't show scroll indicator - self.tabBar.showsHorizontalScrollIndicator = NO; + self.tabBar.theScrollView.showsHorizontalScrollIndicator = NO; self.tabBar.infiniTabBarDelegate = self; self.tabBar.bounces = NO; @@ -169,7 +169,7 @@ - (void)bounces:(UISwitch *)sender { } - (void)showsScrollIndicator:(UISwitch *)sender { - self.tabBar.showsHorizontalScrollIndicator = sender.on; + [self.tabBar setShowsHorizontalScroller:sender.on]; } - (void)setNewItems { diff --git a/InfiniTabBar.h b/InfiniTabBar.h index 3be5e25..42ad8ca 100644 --- a/InfiniTabBar.h +++ b/InfiniTabBar.h @@ -7,20 +7,27 @@ @protocol InfiniTabBarDelegate; -@interface InfiniTabBar : UIScrollView { +@interface InfiniTabBar : UIView { id infiniTabBarDelegate; NSMutableArray *tabBars; UITabBar *aTabBar; UITabBar *bTabBar; + UIScrollView * theScrollView; + UIPageControl * pageControl; } @property (nonatomic, assign) id infiniTabBarDelegate; @property (nonatomic, retain) NSMutableArray *tabBars; @property (nonatomic, retain) UITabBar *aTabBar; @property (nonatomic, retain) UITabBar *bTabBar; +@property (nonatomic, retain) UIPageControl *pageControl; +@property (nonatomic, retain) UIScrollView *theScrollView; - (id)initWithItems:(NSArray *)items; - (void)setBounces:(BOOL)bounces; +- (void)setShowsHorizontalScroller:(BOOL)show; +- (void)setShowsPageControl:(BOOL)showsPageControl; + // Don't set more items than initially - (void)setItems:(NSArray *)items animated:(BOOL)animated; - (int)currentTabBarTag; diff --git a/InfiniTabBar.m b/InfiniTabBar.m index 065bdab..35d9e71 100644 --- a/InfiniTabBar.m +++ b/InfiniTabBar.m @@ -11,23 +11,27 @@ @implementation InfiniTabBar @synthesize tabBars; @synthesize aTabBar; @synthesize bTabBar; +@synthesize pageControl; +@synthesize theScrollView; - (id)initWithItems:(NSArray *)items { - self = [super initWithFrame:CGRectMake(0.0, 411.0, 320.0, 49.0)]; + self = [super initWithFrame:CGRectMake(0.0, 401.0, 320.0, 59.0)]; // TODO: - //self = [super initWithFrame:CGRectMake(self.superview.frame.origin.x + self.superview.frame.size.width - 320.0, self.superview.frame.origin.y + self.superview.frame.size.height - 49.0, 320.0, 49.0)]; + //self = [super initWithFrame:CGRectMake(self.superview.frame.origin.x + self.superview.frame.size.width - 320.0, self.superview.frame.origin.y + self.superview.frame.size.height - 59.0, 320.0, 59.0)]; // Doesn't work. self is nil at this point. if (self) { - self.pagingEnabled = YES; - self.delegate = self; + [self setBackgroundColor:[UIColor blackColor]]; + theScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0, 320.0, 53.0)]; + theScrollView.pagingEnabled = YES; + theScrollView.delegate = self; self.tabBars = [[[NSMutableArray alloc] init] autorelease]; float x = 0.0; for (double d = 0; d < ceil(items.count / 5.0); d ++) { - UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(x, 0.0, 320.0, 49.0)]; + UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(x, 0.0, 320.0, 53.0)]; tabBar.delegate = self; int len = 0; @@ -38,7 +42,7 @@ - (id)initWithItems:(NSArray *)items { tabBar.items = [items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(d * 5, len)]]; - [self addSubview:tabBar]; + [self.theScrollView addSubview:tabBar]; [self.tabBars addObject:tabBar]; @@ -47,7 +51,9 @@ - (id)initWithItems:(NSArray *)items { x += 320.0; } - self.contentSize = CGSizeMake(x, 49.0); + self.theScrollView.contentSize = CGSizeMake(x, 53.0); + [self addSubview:self.theScrollView]; + [self setShowsPageControl:YES]; } return self; @@ -59,21 +65,41 @@ - (void)setBounces:(BOOL)bounces { if (count > 0) { if (self.aTabBar == nil) - self.aTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(-320.0, 0.0, 320.0, 49.0)]autorelease]; + self.aTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(-320.0, 0.0, 320.0, 53.0)]autorelease]; - [self addSubview:self.aTabBar]; + [[self theScrollView] addSubview:self.aTabBar]; if (self.bTabBar == nil) - self.bTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(count * 320.0, 0.0, 320.0, 49.0)] autorelease]; + self.bTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(count * 320.0, 0.0, 320.0, 53.0)] autorelease]; - [self addSubview:self.bTabBar]; + [[self theScrollView] addSubview:self.bTabBar]; } } else { [self.aTabBar removeFromSuperview]; [self.bTabBar removeFromSuperview]; } - [super setBounces:bounces]; + [self.theScrollView setBounces:bounces]; +} + +- (void)setShowsPageControl:(BOOL)showsPageControl { + if(showsPageControl) { + if(!pageControl) { + int count = self.tabBars.count; + pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 45, self.frame.size.width, 20)]; + [pageControl setNumberOfPages:count]; + [self addSubview:pageControl]; + } + + } else if(pageControl) { + [pageControl removeFromSuperview]; + pageControl = nil; + + } +} + +-(void)setShowsHorizontalScroller:(BOOL)show { + [self.theScrollView setShowsHorizontalScrollIndicator:show]; } - (void)setItems:(NSArray *)items animated:(BOOL)animated { @@ -87,11 +113,11 @@ - (void)setItems:(NSArray *)items animated:(BOOL)animated { [tabBar setItems:[items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self.tabBars indexOfObject:tabBar] * 5, len)]] animated:animated]; } - self.contentSize = CGSizeMake(ceil(items.count / 5.0) * 320.0, 49.0); + self.theScrollView.contentSize = CGSizeMake(ceil(items.count / 5.0) * 320.0, 53.0); } - (int)currentTabBarTag { - return self.contentOffset.x / 320.0; + return self.theScrollView.contentOffset.x / 320.0; } - (int)selectedItemTag { @@ -108,10 +134,10 @@ - (BOOL)scrollToTabBarWithTag:(int)tag animated:(BOOL)animated { if ([self.tabBars indexOfObject:tabBar] == tag) { UITabBar *tabBar = [self.tabBars objectAtIndex:tag]; - [self scrollRectToVisible:tabBar.frame animated:animated]; + [self.theScrollView scrollRectToVisible:tabBar.frame animated:animated]; if (animated == NO) - [self scrollViewDidEndDecelerating:self]; + [self scrollViewDidEndDecelerating:self.theScrollView]; return YES; } @@ -134,6 +160,9 @@ - (BOOL)selectItemWithTag:(int)tag { } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { + if(pageControl) { + [pageControl setCurrentPage:scrollView.contentOffset.x / 320.0]; + } [infiniTabBarDelegate infiniTabBar:self didScrollToTabBarWithTag:scrollView.contentOffset.x / 320.0]; } From 045bf23baf3ef58bc4b39226024f95af04d7085f Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Mon, 25 Jun 2012 16:01:05 -0700 Subject: [PATCH 02/10] Changed to 4 items --- InfiniTabBar.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/InfiniTabBar.m b/InfiniTabBar.m index 35d9e71..8587074 100644 --- a/InfiniTabBar.m +++ b/InfiniTabBar.m @@ -30,17 +30,17 @@ - (id)initWithItems:(NSArray *)items { float x = 0.0; - for (double d = 0; d < ceil(items.count / 5.0); d ++) { + for (double d = 0; d < ceil(items.count / 4.0); d ++) { UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(x, 0.0, 320.0, 53.0)]; tabBar.delegate = self; int len = 0; - for (int i = d * 5; i < d * 5 + 5; i ++) + for (int i = d * 4; i < d * 4 + 4; i ++) if (i < items.count) len ++; - tabBar.items = [items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(d * 5, len)]]; + tabBar.items = [items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(d * 4, len)]]; [self.theScrollView addSubview:tabBar]; @@ -106,14 +106,14 @@ - (void)setItems:(NSArray *)items animated:(BOOL)animated { for (UITabBar *tabBar in self.tabBars) { int len = 0; - for (int i = [self.tabBars indexOfObject:tabBar] * 5; i < [self.tabBars indexOfObject:tabBar] * 5 + 5; i ++) + for (int i = [self.tabBars indexOfObject:tabBar] * 4; i < [self.tabBars indexOfObject:tabBar] * 4 + 4; i ++) if (i < items.count) len ++; - [tabBar setItems:[items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self.tabBars indexOfObject:tabBar] * 5, len)]] animated:animated]; + [tabBar setItems:[items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self.tabBars indexOfObject:tabBar] * 4, len)]] animated:animated]; } - self.theScrollView.contentSize = CGSizeMake(ceil(items.count / 5.0) * 320.0, 53.0); + self.theScrollView.contentSize = CGSizeMake(ceil(items.count / 4.0) * 320.0, 53.0); } - (int)currentTabBarTag { From 486f44ba62a71524149a4f2d632897231196cb0f Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Tue, 26 Jun 2012 12:38:50 -0700 Subject: [PATCH 03/10] Changed Size --- InfiniTabBar.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/InfiniTabBar.m b/InfiniTabBar.m index 8587074..a8c64e3 100644 --- a/InfiniTabBar.m +++ b/InfiniTabBar.m @@ -15,14 +15,14 @@ @implementation InfiniTabBar @synthesize theScrollView; - (id)initWithItems:(NSArray *)items { - self = [super initWithFrame:CGRectMake(0.0, 401.0, 320.0, 59.0)]; + self = [super initWithFrame:CGRectMake(0.0, 300.0, 320.0, 130.0)]; // TODO: //self = [super initWithFrame:CGRectMake(self.superview.frame.origin.x + self.superview.frame.size.width - 320.0, self.superview.frame.origin.y + self.superview.frame.size.height - 59.0, 320.0, 59.0)]; // Doesn't work. self is nil at this point. if (self) { [self setBackgroundColor:[UIColor blackColor]]; - theScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0, 320.0, 53.0)]; + theScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0, 320.0, 130.0)]; theScrollView.pagingEnabled = YES; theScrollView.delegate = self; @@ -31,7 +31,7 @@ - (id)initWithItems:(NSArray *)items { float x = 0.0; for (double d = 0; d < ceil(items.count / 4.0); d ++) { - UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(x, 0.0, 320.0, 53.0)]; + UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(x, 0.0, 320.0, 100.0)]; tabBar.delegate = self; int len = 0; @@ -51,7 +51,7 @@ - (id)initWithItems:(NSArray *)items { x += 320.0; } - self.theScrollView.contentSize = CGSizeMake(x, 53.0); + self.theScrollView.contentSize = CGSizeMake(x, 130.0); [self addSubview:self.theScrollView]; [self setShowsPageControl:YES]; } @@ -65,12 +65,12 @@ - (void)setBounces:(BOOL)bounces { if (count > 0) { if (self.aTabBar == nil) - self.aTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(-320.0, 0.0, 320.0, 53.0)]autorelease]; + self.aTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(-320.0, 0.0, 320.0, 130.0)]autorelease]; [[self theScrollView] addSubview:self.aTabBar]; if (self.bTabBar == nil) - self.bTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(count * 320.0, 0.0, 320.0, 53.0)] autorelease]; + self.bTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(count * 320.0, 0.0, 320.0, 130.0)] autorelease]; [[self theScrollView] addSubview:self.bTabBar]; } @@ -86,7 +86,7 @@ - (void)setShowsPageControl:(BOOL)showsPageControl { if(showsPageControl) { if(!pageControl) { int count = self.tabBars.count; - pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 45, self.frame.size.width, 20)]; + pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, self.frame.size.height-30, self.frame.size.width, 20)]; [pageControl setNumberOfPages:count]; [self addSubview:pageControl]; } @@ -113,7 +113,7 @@ - (void)setItems:(NSArray *)items animated:(BOOL)animated { [tabBar setItems:[items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self.tabBars indexOfObject:tabBar] * 4, len)]] animated:animated]; } - self.theScrollView.contentSize = CGSizeMake(ceil(items.count / 4.0) * 320.0, 53.0); + self.theScrollView.contentSize = CGSizeMake(ceil(items.count / 4.0) * 320.0, 130.0); } - (int)currentTabBarTag { From a85e6e8041a723de24f503205610473366e8d800 Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Wed, 27 Jun 2012 11:44:22 -0700 Subject: [PATCH 04/10] Added a select first item method. --- InfiniTabBar.h | 2 ++ InfiniTabBar.m | 27 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/InfiniTabBar.h b/InfiniTabBar.h index 42ad8ca..b468768 100644 --- a/InfiniTabBar.h +++ b/InfiniTabBar.h @@ -32,6 +32,8 @@ - (void)setItems:(NSArray *)items animated:(BOOL)animated; - (int)currentTabBarTag; - (int)selectedItemTag; +-(void)selectFirstItem:(BOOL)animated; + - (BOOL)scrollToTabBarWithTag:(int)tag animated:(BOOL)animated; - (BOOL)selectItemWithTag:(int)tag; diff --git a/InfiniTabBar.m b/InfiniTabBar.m index a8c64e3..896856b 100644 --- a/InfiniTabBar.m +++ b/InfiniTabBar.m @@ -84,16 +84,17 @@ - (void)setBounces:(BOOL)bounces { - (void)setShowsPageControl:(BOOL)showsPageControl { if(showsPageControl) { - if(!pageControl) { - int count = self.tabBars.count; - pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, self.frame.size.height-30, self.frame.size.width, 20)]; - [pageControl setNumberOfPages:count]; - [self addSubview:pageControl]; + if(!self.pageControl) { + self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, self.frame.size.height-30, self.frame.size.width, 20)]; + + [self addSubview:self.pageControl]; } + int count = self.tabBars.count; + [self.pageControl setNumberOfPages:count]; } else if(pageControl) { - [pageControl removeFromSuperview]; - pageControl = nil; + [self.pageControl removeFromSuperview]; + self.pageControl = nil; } } @@ -105,7 +106,6 @@ -(void)setShowsHorizontalScroller:(BOOL)show { - (void)setItems:(NSArray *)items animated:(BOOL)animated { for (UITabBar *tabBar in self.tabBars) { int len = 0; - for (int i = [self.tabBars indexOfObject:tabBar] * 4; i < [self.tabBars indexOfObject:tabBar] * 4 + 4; i ++) if (i < items.count) len ++; @@ -114,6 +114,10 @@ - (void)setItems:(NSArray *)items animated:(BOOL)animated { } self.theScrollView.contentSize = CGSizeMake(ceil(items.count / 4.0) * 320.0, 130.0); + if(self.pageControl != nil) { + [self.pageControl setNumberOfPages:ceil(items.count / 4.0)]; + } + } - (int)currentTabBarTag { @@ -159,6 +163,13 @@ - (BOOL)selectItemWithTag:(int)tag { return NO; } + +-(void)selectFirstItem:(BOOL)animated { + [self scrollToTabBarWithTag:0 animated:animated]; + UITabBarItem *firstItem = [[[self.tabBars objectAtIndex:0] items] objectAtIndex:0]; + [self selectItemWithTag:firstItem.tag]; +} + - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { if(pageControl) { [pageControl setCurrentPage:scrollView.contentOffset.x / 320.0]; From 21116f9494299b4e7a284898f7f6c53d72fd55da Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Wed, 1 Aug 2012 08:59:52 -0700 Subject: [PATCH 05/10] Fixed schemes --- .../xcschemes/InfiniTabBar.xcscheme | 85 +++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 22 +++++ 2 files changed, 107 insertions(+) create mode 100644 InfiniTabBar.xcodeproj/xcuserdata/daniel_brooks.xcuserdatad/xcschemes/InfiniTabBar.xcscheme create mode 100644 InfiniTabBar.xcodeproj/xcuserdata/daniel_brooks.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/InfiniTabBar.xcodeproj/xcuserdata/daniel_brooks.xcuserdatad/xcschemes/InfiniTabBar.xcscheme b/InfiniTabBar.xcodeproj/xcuserdata/daniel_brooks.xcuserdatad/xcschemes/InfiniTabBar.xcscheme new file mode 100644 index 0000000..caa9b01 --- /dev/null +++ b/InfiniTabBar.xcodeproj/xcuserdata/daniel_brooks.xcuserdatad/xcschemes/InfiniTabBar.xcscheme @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/InfiniTabBar.xcodeproj/xcuserdata/daniel_brooks.xcuserdatad/xcschemes/xcschememanagement.plist b/InfiniTabBar.xcodeproj/xcuserdata/daniel_brooks.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..332bf94 --- /dev/null +++ b/InfiniTabBar.xcodeproj/xcuserdata/daniel_brooks.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + InfiniTabBar.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 1D6058900D05DD3D006BFB54 + + primary + + + + + From b883ea39cb433287d19c8f3cfcef228ab6b79887 Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Wed, 8 Aug 2012 08:51:47 -0700 Subject: [PATCH 06/10] InfiniTabBar color --- InfiniTabBar.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InfiniTabBar.m b/InfiniTabBar.m index 896856b..837b8b7 100644 --- a/InfiniTabBar.m +++ b/InfiniTabBar.m @@ -21,7 +21,7 @@ - (id)initWithItems:(NSArray *)items { // Doesn't work. self is nil at this point. if (self) { - [self setBackgroundColor:[UIColor blackColor]]; + [self setBackgroundColor:[UIColor clearColor]]; theScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0, 320.0, 130.0)]; theScrollView.pagingEnabled = YES; theScrollView.delegate = self; From f7ac5ae0776fc51df7d80372d10183b64f6db6a1 Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Mon, 13 Aug 2012 09:08:01 -0700 Subject: [PATCH 07/10] InfiniTabBar color --- InfiniTabBar.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/InfiniTabBar.m b/InfiniTabBar.m index 837b8b7..c9b2492 100644 --- a/InfiniTabBar.m +++ b/InfiniTabBar.m @@ -15,14 +15,14 @@ @implementation InfiniTabBar @synthesize theScrollView; - (id)initWithItems:(NSArray *)items { - self = [super initWithFrame:CGRectMake(0.0, 300.0, 320.0, 130.0)]; + self = [super initWithFrame:CGRectMake(0.0, 300.0, 320.0, 110.0)]; // TODO: //self = [super initWithFrame:CGRectMake(self.superview.frame.origin.x + self.superview.frame.size.width - 320.0, self.superview.frame.origin.y + self.superview.frame.size.height - 59.0, 320.0, 59.0)]; // Doesn't work. self is nil at this point. if (self) { [self setBackgroundColor:[UIColor clearColor]]; - theScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0, 320.0, 130.0)]; + theScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0, 320.0, 110.0)]; theScrollView.pagingEnabled = YES; theScrollView.delegate = self; @@ -31,7 +31,7 @@ - (id)initWithItems:(NSArray *)items { float x = 0.0; for (double d = 0; d < ceil(items.count / 4.0); d ++) { - UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(x, 0.0, 320.0, 100.0)]; + UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(x, 0.0, 320.0, 80.0)]; tabBar.delegate = self; int len = 0; @@ -51,7 +51,7 @@ - (id)initWithItems:(NSArray *)items { x += 320.0; } - self.theScrollView.contentSize = CGSizeMake(x, 130.0); + self.theScrollView.contentSize = CGSizeMake(x, 110.0); [self addSubview:self.theScrollView]; [self setShowsPageControl:YES]; } @@ -65,12 +65,12 @@ - (void)setBounces:(BOOL)bounces { if (count > 0) { if (self.aTabBar == nil) - self.aTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(-320.0, 0.0, 320.0, 130.0)]autorelease]; + self.aTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(-320.0, 0.0, 320.0, 110.0)]autorelease]; [[self theScrollView] addSubview:self.aTabBar]; if (self.bTabBar == nil) - self.bTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(count * 320.0, 0.0, 320.0, 130.0)] autorelease]; + self.bTabBar = [[[UITabBar alloc] initWithFrame:CGRectMake(count * 320.0, 0.0, 320.0, 110.0)] autorelease]; [[self theScrollView] addSubview:self.bTabBar]; } @@ -113,7 +113,7 @@ - (void)setItems:(NSArray *)items animated:(BOOL)animated { [tabBar setItems:[items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self.tabBars indexOfObject:tabBar] * 4, len)]] animated:animated]; } - self.theScrollView.contentSize = CGSizeMake(ceil(items.count / 4.0) * 320.0, 130.0); + self.theScrollView.contentSize = CGSizeMake(ceil(items.count / 4.0) * 320.0, 110.0); if(self.pageControl != nil) { [self.pageControl setNumberOfPages:ceil(items.count / 4.0)]; } From ef727f88ff82128b2e82a5cb6efcd1c96d2ca32d Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Wed, 15 Aug 2012 10:52:30 -0700 Subject: [PATCH 08/10] added error checking to infinitabbar --- InfiniTabBar.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/InfiniTabBar.m b/InfiniTabBar.m index c9b2492..1a483ca 100644 --- a/InfiniTabBar.m +++ b/InfiniTabBar.m @@ -166,8 +166,12 @@ - (BOOL)selectItemWithTag:(int)tag { -(void)selectFirstItem:(BOOL)animated { [self scrollToTabBarWithTag:0 animated:animated]; - UITabBarItem *firstItem = [[[self.tabBars objectAtIndex:0] items] objectAtIndex:0]; - [self selectItemWithTag:firstItem.tag]; + if([self.tabBars count] > 0) { + UITabBarItem *firstItem = [[[self.tabBars objectAtIndex:0] items] objectAtIndex:0]; + [self selectItemWithTag:firstItem.tag]; + } + + } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { From c4947b3f42c6d85caa7fa1485346a36830039bb8 Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Fri, 17 Aug 2012 11:20:22 -0700 Subject: [PATCH 09/10] Made infinitabbar remove tab bars properly and add tab bars --- InfiniTabBar.m | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/InfiniTabBar.m b/InfiniTabBar.m index 1a483ca..2ef5da7 100644 --- a/InfiniTabBar.m +++ b/InfiniTabBar.m @@ -104,18 +104,54 @@ -(void)setShowsHorizontalScroller:(BOOL)show { } - (void)setItems:(NSArray *)items animated:(BOOL)animated { + int itemCount = 0; + + if(ceil(items.count / 4.0) < self.tabBars.count) { + for(int i = self.tabBars.count-1; i+1 > ceil(items.count / 4.0); i--) { + [self.tabBars removeObjectAtIndex:i]; + } + } + for (UITabBar *tabBar in self.tabBars) { int len = 0; for (int i = [self.tabBars indexOfObject:tabBar] * 4; i < [self.tabBars indexOfObject:tabBar] * 4 + 4; i ++) if (i < items.count) len ++; - [tabBar setItems:[items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self.tabBars indexOfObject:tabBar] * 4, len)]] animated:animated]; - } + itemCount = itemCount + tabBar.items.count; + + } + + + + float x = self.tabBars.count * 320; + + if(itemCount != items.count) { + for (double d = self.tabBars.count; d < ceil(items.count / 4.0); d ++) { + UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(x, 0.0, 320.0, 80.0)]; + tabBar.delegate = self; + + int len = 0; + + for (int i = d * 4; i < d * 4 + 4; i ++) + if (i < items.count) + len ++; + + tabBar.items = [items objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(d * 4, len)]]; + + [self.theScrollView addSubview:tabBar]; + + [self.tabBars addObject:tabBar]; + + [tabBar release]; + + x += 320.0; + } + } - self.theScrollView.contentSize = CGSizeMake(ceil(items.count / 4.0) * 320.0, 110.0); + self.theScrollView.contentSize = CGSizeMake(self.tabBars.count * 320.0, 110.0); if(self.pageControl != nil) { - [self.pageControl setNumberOfPages:ceil(items.count / 4.0)]; + [self.pageControl setNumberOfPages:self.tabBars.count]; } } From 26ecfe5445c0acfc00cd880077256cd6e09937fc Mon Sep 17 00:00:00 2001 From: Daniel brooks Date: Tue, 4 Dec 2012 09:56:16 -0800 Subject: [PATCH 10/10] no message --- InfiniTabBar.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InfiniTabBar.m b/InfiniTabBar.m index 2ef5da7..eab6e3a 100644 --- a/InfiniTabBar.m +++ b/InfiniTabBar.m @@ -86,7 +86,7 @@ - (void)setShowsPageControl:(BOOL)showsPageControl { if(showsPageControl) { if(!self.pageControl) { self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, self.frame.size.height-30, self.frame.size.width, 20)]; - + [self.pageControl setEnabled:FALSE]; [self addSubview:self.pageControl]; } int count = self.tabBars.count;