Skip to content

Commit

Permalink
Add a new example page
Browse files Browse the repository at this point in the history
  • Loading branch information
yeatse committed Sep 21, 2016
1 parent 02c8261 commit 46bb986
Show file tree
Hide file tree
Showing 17 changed files with 402 additions and 7 deletions.
29 changes: 29 additions & 0 deletions Example/YTPageController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
38C5996E1D91875400CC7588 /* SegmentedControlTransitionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 38C599681D91875400CC7588 /* SegmentedControlTransitionDelegate.m */; };
38C5996F1D91875400CC7588 /* TabBarTransition.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 38C5996A1D91875400CC7588 /* TabBarTransition.storyboard */; };
38C599701D91875400CC7588 /* TabBarTransitionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 38C5996C1D91875400CC7588 /* TabBarTransitionDelegate.m */; };
38E1219D1D925C3D00376048 /* DynamicPages.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 38E1219C1D925C3D00376048 /* DynamicPages.storyboard */; };
38E121A11D925C8F00376048 /* DynamicPagesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 38E121A01D925C8F00376048 /* DynamicPagesViewController.m */; };
38E121A41D925D1F00376048 /* DynamicPagesChildViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 38E121A31D925D1F00376048 /* DynamicPagesChildViewController.m */; };
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; };
6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
Expand Down Expand Up @@ -50,6 +53,11 @@
38C5996A1D91875400CC7588 /* TabBarTransition.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = TabBarTransition.storyboard; sourceTree = "<group>"; };
38C5996B1D91875400CC7588 /* TabBarTransitionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TabBarTransitionDelegate.h; sourceTree = "<group>"; };
38C5996C1D91875400CC7588 /* TabBarTransitionDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TabBarTransitionDelegate.m; sourceTree = "<group>"; };
38E1219C1D925C3D00376048 /* DynamicPages.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = DynamicPages.storyboard; path = "Dynamic Pages/DynamicPages.storyboard"; sourceTree = "<group>"; };
38E1219F1D925C8F00376048 /* DynamicPagesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DynamicPagesViewController.h; path = "Dynamic Pages/DynamicPagesViewController.h"; sourceTree = "<group>"; };
38E121A01D925C8F00376048 /* DynamicPagesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DynamicPagesViewController.m; path = "Dynamic Pages/DynamicPagesViewController.m"; sourceTree = "<group>"; };
38E121A21D925D1F00376048 /* DynamicPagesChildViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DynamicPagesChildViewController.h; path = "Dynamic Pages/DynamicPagesChildViewController.h"; sourceTree = "<group>"; };
38E121A31D925D1F00376048 /* DynamicPagesChildViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DynamicPagesChildViewController.m; path = "Dynamic Pages/DynamicPagesChildViewController.m"; sourceTree = "<group>"; };
6003F58A195388D20070C39A /* YTPageController_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YTPageController_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
6003F58F195388D20070C39A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -122,6 +130,18 @@
path = "Tab Bar Transition";
sourceTree = "<group>";
};
38E1219E1D925C4100376048 /* Dynamic Pages */ = {
isa = PBXGroup;
children = (
38E1219C1D925C3D00376048 /* DynamicPages.storyboard */,
38E1219F1D925C8F00376048 /* DynamicPagesViewController.h */,
38E121A01D925C8F00376048 /* DynamicPagesViewController.m */,
38E121A21D925D1F00376048 /* DynamicPagesChildViewController.h */,
38E121A31D925D1F00376048 /* DynamicPagesChildViewController.m */,
);
name = "Dynamic Pages";
sourceTree = "<group>";
};
6003F581195388D10070C39A = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -163,6 +183,7 @@
6003F59D195388D20070C39A /* YTAppDelegate.m */,
38C599651D91875400CC7588 /* Segmented Control Transition */,
38C599691D91875400CC7588 /* Tab Bar Transition */,
38E1219E1D925C4100376048 /* Dynamic Pages */,
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */,
38AD3E3D1D91519900AFC8E0 /* Launch Screen.storyboard */,
6003F5A8195388D20070C39A /* Images.xcassets */,
Expand Down Expand Up @@ -277,6 +298,9 @@
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Yeatse CC";
TargetAttributes = {
6003F589195388D20070C39A = {
DevelopmentTeam = L6JP27B8YR;
};
6003F5AD195388D20070C39A = {
TestTargetID = 6003F589195388D20070C39A;
};
Expand Down Expand Up @@ -310,6 +334,7 @@
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */,
6003F5A9195388D20070C39A /* Images.xcassets in Resources */,
38C5996F1D91875400CC7588 /* TabBarTransition.storyboard in Resources */,
38E1219D1D925C3D00376048 /* DynamicPages.storyboard in Resources */,
38AD3E3E1D91519900AFC8E0 /* Launch Screen.storyboard in Resources */,
6003F598195388D20070C39A /* InfoPlist.strings in Resources */,
);
Expand Down Expand Up @@ -426,6 +451,8 @@
6003F59E195388D20070C39A /* YTAppDelegate.m in Sources */,
38C5996E1D91875400CC7588 /* SegmentedControlTransitionDelegate.m in Sources */,
6003F59A195388D20070C39A /* main.m in Sources */,
38E121A11D925C8F00376048 /* DynamicPagesViewController.m in Sources */,
38E121A41D925D1F00376048 /* DynamicPagesChildViewController.m in Sources */,
38C599701D91875400CC7588 /* TabBarTransitionDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -556,6 +583,7 @@
baseConfigurationReference = 2A0ABC29729E9737CB648D9D /* Pods-YTPageController_Example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = L6JP27B8YR;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "YTPageController/YTPageController-Prefix.pch";
INFOPLIST_FILE = "YTPageController/YTPageController-Info.plist";
Expand All @@ -571,6 +599,7 @@
baseConfigurationReference = ED8189557335C8F0DAB6FA13 /* Pods-YTPageController_Example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = L6JP27B8YR;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "YTPageController/YTPageController-Prefix.pch";
INFOPLIST_FILE = "YTPageController/YTPageController-Info.plist";
Expand Down
86 changes: 86 additions & 0 deletions Example/YTPageController/Dynamic Pages/DynamicPages.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="66Y-dS-GAl">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Dynamic Pages-->
<scene sceneID="6bz-6h-j9u">
<objects>
<viewController title="Dynamic Pages" id="66Y-dS-GAl" customClass="DynamicPagesViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="dlh-G6-DSn"/>
<viewControllerLayoutGuide type="bottom" id="ggm-Wk-QDu"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="ZJQ-OK-dYz">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tabBar contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="N5B-ql-jbb">
<frame key="frameInset" height="49"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<items/>
<connections>
<outlet property="delegate" destination="66Y-dS-GAl" id="Ug9-1G-FiG"/>
</connections>
</tabBar>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" title="Dynamic Pages" id="JBp-jT-Hvp">
<barButtonItem key="rightBarButtonItem" title="Reload" id="i26-AO-lpk">
<connections>
<action selector="reloadPages:" destination="66Y-dS-GAl" id="JcH-DP-UlG"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="bounces" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="tabBar" destination="N5B-ql-jbb" id="HlG-5S-8oE"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="BSj-Q8-mSl" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="220" y="114"/>
</scene>
<!--Child View Controller-->
<scene sceneID="wTU-GT-zRj">
<objects>
<viewController storyboardIdentifier="ChildViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Nwk-LD-gE9" userLabel="Child View Controller" customClass="DynamicPagesChildViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="MLV-m9-qyy"/>
<viewControllerLayoutGuide type="bottom" id="hXp-hT-GIl"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="4CR-DT-ZeE">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QeT-e9-Ieh">
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="QeT-e9-Ieh" firstAttribute="top" secondItem="4CR-DT-ZeE" secondAttribute="topMargin" constant="156" id="7Fr-PZ-QtU"/>
<constraint firstItem="QeT-e9-Ieh" firstAttribute="centerX" secondItem="4CR-DT-ZeE" secondAttribute="centerX" id="J2N-h0-x4x"/>
</constraints>
</view>
<connections>
<outlet property="label" destination="QeT-e9-Ieh" id="TBQ-WN-CkW"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Rec-jv-gqm" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1047" y="114"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// DynamicPagesChildViewController.h
// YTPageController
//
// Created by yeatse on 16/9/21.
// Copyright © 2016年 Yeatse CC. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface DynamicPagesChildViewController : UIViewController

@property (weak, nonatomic) IBOutlet UILabel *label;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// DynamicPagesChildViewController.m
// YTPageController
//
// Created by yeatse on 16/9/21.
// Copyright © 2016年 Yeatse CC. All rights reserved.
//

#import "DynamicPagesChildViewController.h"

@interface DynamicPagesChildViewController ()

@end

@implementation DynamicPagesChildViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.label.text = self.title;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// DynamicPagesViewController.h
// YTPageController
//
// Created by yeatse on 16/9/21.
// Copyright © 2016年 Yeatse CC. All rights reserved.
//

#import <YTPageController/YTPageController.h>

@interface DynamicPagesViewController : YTPageController

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//
// DynamicPagesViewController.m
// YTPageController
//
// Created by yeatse on 16/9/21.
// Copyright © 2016年 Yeatse CC. All rights reserved.
//

#import "DynamicPagesViewController.h"
#import "DynamicPagesChildViewController.h"

@interface DynamicPagesViewController ()<YTPageControllerDelegate, YTPageControllerDataSource, UITabBarDelegate>

@property (weak, nonatomic) IBOutlet UITabBar *tabBar;

@end

@implementation DynamicPagesViewController {
NSArray<NSString*>* _pageNames1;
NSArray<NSString*>* _pageNames2;
BOOL _flag;
}

- (void)viewDidLoad {
[super viewDidLoad];

self.delegate = self;
self.dataSource = self;

_pageNames1 = @[@"First", @"Second", @"Third"];
_pageNames2 = @[@"Eins", @"Zwei", @"Drei", @"Vier"];

[self reloadPages];
[self refreshTabBarItems];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

- (IBAction)reloadPages:(id)sender {
_flag = !_flag;
self.currentIndex = 0;
[self reloadPages];
[self refreshTabBarItems];
}

- (void)refreshTabBarItems {
NSMutableArray<UITabBarItem*>* items = @[].mutableCopy;
for (NSString* name in _flag ? _pageNames2 : _pageNames1) {
UITabBarItem* item = [[UITabBarItem alloc] initWithTitle:name image:[UIImage imageNamed:@"tabbar_icon"] selectedImage:[UIImage imageNamed:@"tabbar_icon_hl"]];
[items addObject:item];
}
self.tabBar.items = items;
self.tabBar.selectedItem = self.tabBar.items[self.currentIndex];
}

#pragma mark - YTPageControllerDelegate

- (void)pageController:(YTPageController *)pageController willTransitionToIndex:(NSInteger)index {
[self.pageCoordinator animateAlongsidePagingInView:self.tabBar animation:^(id<YTPageTransitionContext> _Nonnull context) {
self.tabBar.selectedItem = self.tabBar.items[[context toIndex]];
} completion:^(id<YTPageTransitionContext> _Nonnull context) {
if ([context isCanceled]) {
self.tabBar.selectedItem = self.tabBar.items[[context fromIndex]];
}
}];
}

- (void)pageController:(YTPageController *)pageController didUpdateTransition:(id<YTPageTransitionContext>)context {
NSLog(@"%s, offset: %f", __func__, [context relativeOffset]);
}

- (void)pageController:(YTPageController *)pageController didEndTransition:(id<YTPageTransitionContext>)context {
NSLog(@"%s from %zd to %zd, canceled: %d", __func__, [context fromIndex], [context toIndex], [context isCanceled]);
}

#pragma mark - YTPageControllerDataSource

- (NSInteger)numberOfPagesInPageController:(YTPageController *)pageController {
return _flag ? _pageNames2.count : _pageNames1.count;
}

- (UIViewController *)pageController:(YTPageController *)pageController pageAtIndex:(NSInteger)index {
DynamicPagesChildViewController* childVC = [self.storyboard instantiateViewControllerWithIdentifier:@"ChildViewController"];
childVC.title = (_flag ? _pageNames2 : _pageNames1)[index];
return childVC;
}

#pragma mark - UITabBarDelegate

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
self.currentIndex = [tabBar.items indexOfObjectIdenticalTo:item];
}

@end
Loading

0 comments on commit 46bb986

Please sign in to comment.