Skip to content

Commit bd3bf39

Browse files
committed
chapter 6 up thru unwind segues
1 parent 0a7033e commit bd3bf39

File tree

23 files changed

+822
-60
lines changed

23 files changed

+822
-60
lines changed

bk2ch06p304customPresentedAnimation2/ch19p620customPresentedAnimation2/ViewControllers.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ extension CGVector {
2323
}
2424

2525

26-
27-
28-
class ViewController : UIViewController {
29-
@IBAction func doButton(_ sender:AnyObject?) {
30-
// for comparison purposes
26+
// for comparison purposes
3127
// let alert = UIAlertController(title: "Howdy", message: "This is a test", preferredStyle: .Alert)
3228
// alert.addAction(UIAlertAction(title: "OK", style: .Cancel))
3329
// self.present(alert, animated:true)
3430
// return;
31+
32+
33+
class ViewController : UIViewController {
34+
@IBAction func doButton(_ sender:AnyObject?) {
3535
self.present(ViewController2(), animated:true)
3636
}
3737
}
@@ -146,10 +146,12 @@ class MyPresentationController : UIPresentationController {
146146
extension ViewController2 /* UIViewControllerTransitioningDelegate */ {
147147
@objc(animationControllerForPresentedController:presentingController:sourceController:)
148148
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
149+
print("providing presentation animation controller")
149150
return self
150151
}
151152
@objc(animationControllerForDismissedController:)
152153
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
154+
print("providing dismissal animation controller")
153155
return self
154156
}
155157
}
@@ -161,8 +163,10 @@ extension ViewController2 : UIViewControllerAnimatedTransitioning {
161163
}
162164

163165
func animateTransition(using ctx: UIViewControllerContextTransitioning) {
164-
// let vc1 = ctx.viewController(forKey:UITransitionContextFromViewControllerKey)
165-
// let vc2 = ctx.viewController(forKey:UITransitionContextToViewControllerKey)
166+
// just for logging purposes
167+
let vc1 = ctx.viewController(forKey:UITransitionContextFromViewControllerKey)
168+
let vc2 = ctx.viewController(forKey:UITransitionContextToViewControllerKey)
169+
print("vc1 is", vc1!.dynamicType, "\nvc2 is", vc2!.dynamicType)
166170

167171
let con = ctx.containerView
168172

@@ -175,8 +179,10 @@ extension ViewController2 : UIViewControllerAnimatedTransitioning {
175179
// we are using the same object (self) as animation controller
176180
// for both presentation and dismissal
177181
// so we have to distinguish the two cases
182+
// warning: this trick works only for non-fullscreen
178183

179-
if let v2 = v2 {
184+
if let v2 = v2 { // presenting
185+
print("presentation animation")
180186
con.addSubview(v2)
181187
let scale = CGAffineTransform(scaleX:1.6, y:1.6)
182188
v2.transform = scale
@@ -188,7 +194,8 @@ extension ViewController2 : UIViewControllerAnimatedTransitioning {
188194
_ in
189195
ctx.completeTransition(true)
190196
})
191-
} else if let v1 = v1 {
197+
} else if let v1 = v1 { // dismissing
198+
print("dismissal animation")
192199
UIView.animate(withDuration:0.25, animations: {
193200
v1.alpha = 0
194201
}, completion: {
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
3208B9741979B0AA005695E6 /* Pep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3208B9731979B0AA005695E6 /* Pep.swift */; };
11+
3208B9761979B243005695E6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3208B9751979B243005695E6 /* AppDelegate.swift */; };
12+
32F99CD51B7915980056D3FD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32F99CD41B7915980056D3FD /* LaunchScreen.storyboard */; };
13+
81EB46871D5F75310098A74F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81EB46861D5F75310098A74F /* Main.storyboard */; };
14+
81EB46891D5F75610098A74F /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81EB46881D5F75610098A74F /* RootViewController.swift */; };
15+
C94F83C917CFAC7A00DA797B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C94F83C817CFAC7A00DA797B /* Assets.xcassets */; };
16+
C94F83EF17CFACB400DA797B /* Pep.xib in Resources */ = {isa = PBXBuildFile; fileRef = C94F83ED17CFACB400DA797B /* Pep.xib */; };
17+
/* End PBXBuildFile section */
18+
19+
/* Begin PBXFileReference section */
20+
3208B9731979B0AA005695E6 /* Pep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Pep.swift; sourceTree = "<group>"; };
21+
3208B9751979B243005695E6 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
22+
32F99CD41B7915980056D3FD /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
23+
81EB46861D5F75310098A74F /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
24+
81EB46881D5F75610098A74F /* RootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
25+
C94F83B317CFAC7A00DA797B /* ch19p626pageController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ch19p626pageController.app; sourceTree = BUILT_PRODUCTS_DIR; };
26+
C94F83BE17CFAC7A00DA797B /* ch19p626pageController-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ch19p626pageController-Info.plist"; sourceTree = "<group>"; };
27+
C94F83C817CFAC7A00DA797B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
28+
C94F83ED17CFACB400DA797B /* Pep.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Pep.xib; sourceTree = "<group>"; };
29+
/* End PBXFileReference section */
30+
31+
/* Begin PBXFrameworksBuildPhase section */
32+
C94F83B017CFAC7A00DA797B /* Frameworks */ = {
33+
isa = PBXFrameworksBuildPhase;
34+
buildActionMask = 2147483647;
35+
files = (
36+
);
37+
runOnlyForDeploymentPostprocessing = 0;
38+
};
39+
/* End PBXFrameworksBuildPhase section */
40+
41+
/* Begin PBXGroup section */
42+
C94F83AA17CFAC7900DA797B = {
43+
isa = PBXGroup;
44+
children = (
45+
C94F83BC17CFAC7A00DA797B /* ch19p626pageController */,
46+
C94F83B417CFAC7A00DA797B /* Products */,
47+
);
48+
sourceTree = "<group>";
49+
};
50+
C94F83B417CFAC7A00DA797B /* Products */ = {
51+
isa = PBXGroup;
52+
children = (
53+
C94F83B317CFAC7A00DA797B /* ch19p626pageController.app */,
54+
);
55+
name = Products;
56+
sourceTree = "<group>";
57+
};
58+
C94F83BC17CFAC7A00DA797B /* ch19p626pageController */ = {
59+
isa = PBXGroup;
60+
children = (
61+
3208B9751979B243005695E6 /* AppDelegate.swift */,
62+
81EB46861D5F75310098A74F /* Main.storyboard */,
63+
81EB46881D5F75610098A74F /* RootViewController.swift */,
64+
3208B9731979B0AA005695E6 /* Pep.swift */,
65+
C94F83ED17CFACB400DA797B /* Pep.xib */,
66+
C94F83C817CFAC7A00DA797B /* Assets.xcassets */,
67+
32F99CD41B7915980056D3FD /* LaunchScreen.storyboard */,
68+
C94F83BE17CFAC7A00DA797B /* ch19p626pageController-Info.plist */,
69+
);
70+
path = ch19p626pageController;
71+
sourceTree = "<group>";
72+
};
73+
/* End PBXGroup section */
74+
75+
/* Begin PBXNativeTarget section */
76+
C94F83B217CFAC7A00DA797B /* ch19p626pageController */ = {
77+
isa = PBXNativeTarget;
78+
buildConfigurationList = C94F83DF17CFAC7A00DA797B /* Build configuration list for PBXNativeTarget "ch19p626pageController" */;
79+
buildPhases = (
80+
C94F83AF17CFAC7A00DA797B /* Sources */,
81+
C94F83B017CFAC7A00DA797B /* Frameworks */,
82+
C94F83B117CFAC7A00DA797B /* Resources */,
83+
);
84+
buildRules = (
85+
);
86+
dependencies = (
87+
);
88+
name = ch19p626pageController;
89+
productName = ch19p626pageController;
90+
productReference = C94F83B317CFAC7A00DA797B /* ch19p626pageController.app */;
91+
productType = "com.apple.product-type.application";
92+
};
93+
/* End PBXNativeTarget section */
94+
95+
/* Begin PBXProject section */
96+
C94F83AB17CFAC7900DA797B /* Project object */ = {
97+
isa = PBXProject;
98+
attributes = {
99+
LastSwiftUpdateCheck = 0700;
100+
LastUpgradeCheck = 0500;
101+
ORGANIZATIONNAME = "Matt Neuburg";
102+
TargetAttributes = {
103+
C94F83B217CFAC7A00DA797B = {
104+
LastSwiftMigration = 0800;
105+
};
106+
};
107+
};
108+
buildConfigurationList = C94F83AE17CFAC7A00DA797B /* Build configuration list for PBXProject "ch19p626pageController" */;
109+
compatibilityVersion = "Xcode 3.2";
110+
developmentRegion = English;
111+
hasScannedForEncodings = 0;
112+
knownRegions = (
113+
en,
114+
);
115+
mainGroup = C94F83AA17CFAC7900DA797B;
116+
productRefGroup = C94F83B417CFAC7A00DA797B /* Products */;
117+
projectDirPath = "";
118+
projectRoot = "";
119+
targets = (
120+
C94F83B217CFAC7A00DA797B /* ch19p626pageController */,
121+
);
122+
};
123+
/* End PBXProject section */
124+
125+
/* Begin PBXResourcesBuildPhase section */
126+
C94F83B117CFAC7A00DA797B /* Resources */ = {
127+
isa = PBXResourcesBuildPhase;
128+
buildActionMask = 2147483647;
129+
files = (
130+
C94F83EF17CFACB400DA797B /* Pep.xib in Resources */,
131+
32F99CD51B7915980056D3FD /* LaunchScreen.storyboard in Resources */,
132+
C94F83C917CFAC7A00DA797B /* Assets.xcassets in Resources */,
133+
81EB46871D5F75310098A74F /* Main.storyboard in Resources */,
134+
);
135+
runOnlyForDeploymentPostprocessing = 0;
136+
};
137+
/* End PBXResourcesBuildPhase section */
138+
139+
/* Begin PBXSourcesBuildPhase section */
140+
C94F83AF17CFAC7A00DA797B /* Sources */ = {
141+
isa = PBXSourcesBuildPhase;
142+
buildActionMask = 2147483647;
143+
files = (
144+
3208B9761979B243005695E6 /* AppDelegate.swift in Sources */,
145+
3208B9741979B0AA005695E6 /* Pep.swift in Sources */,
146+
81EB46891D5F75610098A74F /* RootViewController.swift in Sources */,
147+
);
148+
runOnlyForDeploymentPostprocessing = 0;
149+
};
150+
/* End PBXSourcesBuildPhase section */
151+
152+
/* Begin XCBuildConfiguration section */
153+
C94F83DD17CFAC7A00DA797B /* Debug */ = {
154+
isa = XCBuildConfiguration;
155+
buildSettings = {
156+
ALWAYS_SEARCH_USER_PATHS = NO;
157+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
158+
CLANG_CXX_LIBRARY = "libc++";
159+
CLANG_ENABLE_MODULES = YES;
160+
CLANG_ENABLE_OBJC_ARC = YES;
161+
CLANG_WARN_BOOL_CONVERSION = YES;
162+
CLANG_WARN_CONSTANT_CONVERSION = YES;
163+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
164+
CLANG_WARN_EMPTY_BODY = YES;
165+
CLANG_WARN_ENUM_CONVERSION = YES;
166+
CLANG_WARN_INT_CONVERSION = YES;
167+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
168+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
169+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
170+
COPY_PHASE_STRIP = NO;
171+
GCC_C_LANGUAGE_STANDARD = gnu99;
172+
GCC_DYNAMIC_NO_PIC = NO;
173+
GCC_OPTIMIZATION_LEVEL = 0;
174+
GCC_PREPROCESSOR_DEFINITIONS = (
175+
"DEBUG=1",
176+
"$(inherited)",
177+
);
178+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
179+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
180+
GCC_WARN_UNDECLARED_SELECTOR = YES;
181+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
182+
GCC_WARN_UNUSED_FUNCTION = YES;
183+
GCC_WARN_UNUSED_VARIABLE = YES;
184+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
185+
ONLY_ACTIVE_ARCH = YES;
186+
SDKROOT = iphoneos;
187+
};
188+
name = Debug;
189+
};
190+
C94F83DE17CFAC7A00DA797B /* Release */ = {
191+
isa = XCBuildConfiguration;
192+
buildSettings = {
193+
ALWAYS_SEARCH_USER_PATHS = NO;
194+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
195+
CLANG_CXX_LIBRARY = "libc++";
196+
CLANG_ENABLE_MODULES = YES;
197+
CLANG_ENABLE_OBJC_ARC = YES;
198+
CLANG_WARN_BOOL_CONVERSION = YES;
199+
CLANG_WARN_CONSTANT_CONVERSION = YES;
200+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
201+
CLANG_WARN_EMPTY_BODY = YES;
202+
CLANG_WARN_ENUM_CONVERSION = YES;
203+
CLANG_WARN_INT_CONVERSION = YES;
204+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
205+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
206+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
207+
COPY_PHASE_STRIP = YES;
208+
ENABLE_NS_ASSERTIONS = NO;
209+
GCC_C_LANGUAGE_STANDARD = gnu99;
210+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
211+
GCC_WARN_UNDECLARED_SELECTOR = YES;
212+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
213+
GCC_WARN_UNUSED_FUNCTION = YES;
214+
GCC_WARN_UNUSED_VARIABLE = YES;
215+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
216+
SDKROOT = iphoneos;
217+
VALIDATE_PRODUCT = YES;
218+
};
219+
name = Release;
220+
};
221+
C94F83E017CFAC7A00DA797B /* Debug */ = {
222+
isa = XCBuildConfiguration;
223+
buildSettings = {
224+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
225+
CLANG_ENABLE_MODULES = YES;
226+
GCC_PRECOMPILE_PREFIX_HEADER = YES;
227+
GCC_PREFIX_HEADER = "";
228+
INFOPLIST_FILE = "ch19p626pageController/ch19p626pageController-Info.plist";
229+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
230+
ONLY_ACTIVE_ARCH = NO;
231+
PRODUCT_NAME = "$(TARGET_NAME)";
232+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
233+
SWIFT_VERSION = 3.0;
234+
WRAPPER_EXTENSION = app;
235+
};
236+
name = Debug;
237+
};
238+
C94F83E117CFAC7A00DA797B /* Release */ = {
239+
isa = XCBuildConfiguration;
240+
buildSettings = {
241+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
242+
CLANG_ENABLE_MODULES = YES;
243+
GCC_PRECOMPILE_PREFIX_HEADER = YES;
244+
GCC_PREFIX_HEADER = "";
245+
INFOPLIST_FILE = "ch19p626pageController/ch19p626pageController-Info.plist";
246+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
247+
ONLY_ACTIVE_ARCH = NO;
248+
PRODUCT_NAME = "$(TARGET_NAME)";
249+
SWIFT_VERSION = 3.0;
250+
WRAPPER_EXTENSION = app;
251+
};
252+
name = Release;
253+
};
254+
/* End XCBuildConfiguration section */
255+
256+
/* Begin XCConfigurationList section */
257+
C94F83AE17CFAC7A00DA797B /* Build configuration list for PBXProject "ch19p626pageController" */ = {
258+
isa = XCConfigurationList;
259+
buildConfigurations = (
260+
C94F83DD17CFAC7A00DA797B /* Debug */,
261+
C94F83DE17CFAC7A00DA797B /* Release */,
262+
);
263+
defaultConfigurationIsVisible = 0;
264+
defaultConfigurationName = Release;
265+
};
266+
C94F83DF17CFAC7A00DA797B /* Build configuration list for PBXNativeTarget "ch19p626pageController" */ = {
267+
isa = XCConfigurationList;
268+
buildConfigurations = (
269+
C94F83E017CFAC7A00DA797B /* Debug */,
270+
C94F83E117CFAC7A00DA797B /* Release */,
271+
);
272+
defaultConfigurationIsVisible = 0;
273+
defaultConfigurationName = Release;
274+
};
275+
/* End XCConfigurationList section */
276+
};
277+
rootObject = C94F83AB17CFAC7900DA797B /* Project object */;
278+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
import UIKit
3+
4+
5+
@UIApplicationMain
6+
class AppDelegate : UIResponder, UIApplicationDelegate {
7+
var window : UIWindow?
8+
9+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
10+
return true
11+
}
12+
13+
14+
15+
}

0 commit comments

Comments
 (0)