Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

Commit

Permalink
Bug fix for tabsView location
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilter Cengiz committed Sep 21, 2013
1 parent dd7df6f commit 857c321
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
3 changes: 3 additions & 0 deletions ICViewPager/Controller/HostViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ - (CGFloat)viewPager:(ViewPagerController *)viewPager valueForOption:(ViewPagerO
case ViewPagerOptionCenterCurrentTab:
return 0.0;
break;
case ViewPagerOptionTabLocation:
return 1.0;
break;
default:
break;
}
Expand Down
45 changes: 28 additions & 17 deletions ICViewPager/ICViewPager/ViewPagerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ @interface ViewPagerController () <UIPageViewControllerDataSource, UIPageViewCon
@property (assign) id<UIScrollViewDelegate> origPageScrollViewDelegate;

@property UIScrollView *tabsView;
@property UIView *contentView;

@property NSMutableArray *tabs;
@property NSMutableArray *contents;
Expand Down Expand Up @@ -123,6 +124,24 @@ - (void)viewDidLoad {

[self reloadData];
}
- (void)viewWillLayoutSubviews {

CGRect frame;

frame = _tabsView.frame;
frame.origin.x = 0.0;
frame.origin.y = self.tabLocation ? 0.0 : self.view.frame.size.height - self.tabHeight;
frame.size.width = self.view.bounds.size.width;
frame.size.height = self.tabHeight;
_tabsView.frame = frame;

frame = _contentView.frame;
frame.origin.x = 0.0;
frame.origin.y = self.tabLocation ? self.tabHeight : 0.0;
frame.size.width = self.view.bounds.size.width;
frame.size.height = self.view.frame.size.height - self.tabHeight;
_contentView.frame = frame;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
Expand Down Expand Up @@ -311,10 +330,7 @@ - (void)reloadData {
}

// Add tabsView
_tabsView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0,
self.tabLocation ? 0.0 : self.view.frame.size.height - self.tabHeight,
self.view.frame.size.width,
self.tabHeight)];
_tabsView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.tabHeight)];
_tabsView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_tabsView.backgroundColor = self.tabsViewBackgroundColor;
_tabsView.showsHorizontalScrollIndicator = NO;
Expand Down Expand Up @@ -345,24 +361,19 @@ - (void)reloadData {
_tabsView.contentSize = CGSizeMake(contentSizeWidth, self.tabHeight);

// Add contentView
UIView *pageView = [self.view viewWithTag:kPageViewTag];
_contentView = [self.view viewWithTag:kPageViewTag];

if (!pageView) {
if (!_contentView) {

pageView = _pageViewController.view;
pageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
pageView.backgroundColor = self.contentViewBackgroundColor;
pageView.bounds = self.view.bounds;
pageView.tag = kPageViewTag;
_contentView = _pageViewController.view;
_contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_contentView.backgroundColor = self.contentViewBackgroundColor;
_contentView.bounds = self.view.bounds;
_contentView.tag = kPageViewTag;

[self.view insertSubview:pageView atIndex:0];
[self.view insertSubview:_contentView atIndex:0];
}

CGRect frame = pageView.frame;
frame.size.height = self.view.frame.size.height - self.tabHeight;
frame.origin.y = self.tabLocation ? self.tabHeight : 0.0;
pageView.frame = frame;

// Set first viewController
UIViewController *viewController;

Expand Down

0 comments on commit 857c321

Please sign in to comment.