Skip to content

Commit 55f0167

Browse files
committed
PageControl: Version 7.0, 2017-09-21
Upgraded to Swift, now uses Storyboards. This application demonstrates how to use a "paginated" UIScrollView to display pages of images in a horizontal fashion as a mechanism for navigating between different pages of content. It is optimized to minimize the memory usage by loading only three image pages at a time the user user scrolls: the current page, the page before and after it. This application was designed as universal to run on both iPhone and iPad devices. Signed-off-by: Liu Lantao <liulantao@gmail.com>
1 parent cc05971 commit 55f0167

File tree

22 files changed

+1010
-0
lines changed

22 files changed

+1010
-0
lines changed

PageControl/LICENSE.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Sample code project: PageControl: Using a Paginated UIScrollView
2+
Version: 7.0
3+
4+
IMPORTANT: This Apple software is supplied to you by Apple
5+
Inc. ("Apple") in consideration of your agreement to the following
6+
terms, and your use, installation, modification or redistribution of
7+
this Apple software constitutes acceptance of these terms. If you do
8+
not agree with these terms, please do not use, install, modify or
9+
redistribute this Apple software.
10+
11+
In consideration of your agreement to abide by the following terms, and
12+
subject to these terms, Apple grants you a personal, non-exclusive
13+
license, under Apple's copyrights in this original Apple software (the
14+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
15+
Software, with or without modifications, in source and/or binary forms;
16+
provided that if you redistribute the Apple Software in its entirety and
17+
without modifications, you must retain this notice and the following
18+
text and disclaimers in all such redistributions of the Apple Software.
19+
Neither the name, trademarks, service marks or logos of Apple Inc. may
20+
be used to endorse or promote products derived from the Apple Software
21+
without specific prior written permission from Apple. Except as
22+
expressly stated in this notice, no other rights or licenses, express or
23+
implied, are granted by Apple herein, including but not limited to any
24+
patent rights that may be infringed by your derivative works or by other
25+
works in which the Apple Software may be incorporated.
26+
27+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
28+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
29+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
30+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
31+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
32+
33+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
34+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
37+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
38+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
39+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
40+
POSSIBILITY OF SUCH DAMAGE.
41+
42+
Copyright (C) 2017 Apple Inc. All Rights Reserved.
Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
53F37B3C1F3B5F8000976FC6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53F37B381F3B5F8000976FC6 /* AppDelegate.swift */; };
11+
53F37B3D1F3B5F8000976FC6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 53F37B391F3B5F8000976FC6 /* Images.xcassets */; };
12+
53F37B3F1F3B5F8000976FC6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53F37B3B1F3B5F8000976FC6 /* ViewController.swift */; };
13+
53F37B441F3B5F9100976FC6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 53F37B401F3B5F9100976FC6 /* LaunchScreen.storyboard */; };
14+
53F37B451F3B5F9100976FC6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 53F37B421F3B5F9100976FC6 /* Main.storyboard */; };
15+
/* End PBXBuildFile section */
16+
17+
/* Begin PBXFileReference section */
18+
531AABED193D204000E16ED6 /* PageControl.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PageControl.app; sourceTree = BUILT_PRODUCTS_DIR; };
19+
535B260D1F3E0F7F006A5EF0 /* ReadMe.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = ReadMe.md; sourceTree = "<group>"; };
20+
53F37B381F3B5F8000976FC6 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = PageControl/AppDelegate.swift; sourceTree = "<group>"; };
21+
53F37B391F3B5F8000976FC6 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = PageControl/Images.xcassets; sourceTree = "<group>"; };
22+
53F37B3A1F3B5F8000976FC6 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = PageControl/Info.plist; sourceTree = "<group>"; };
23+
53F37B3B1F3B5F8000976FC6 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ViewController.swift; path = PageControl/ViewController.swift; sourceTree = "<group>"; };
24+
53F37B411F3B5F9100976FC6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = PageControl/Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
25+
53F37B431F3B5F9100976FC6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = PageControl/Base.lproj/Main.storyboard; sourceTree = "<group>"; };
26+
/* End PBXFileReference section */
27+
28+
/* Begin PBXFrameworksBuildPhase section */
29+
531AABEA193D204000E16ED6 /* Frameworks */ = {
30+
isa = PBXFrameworksBuildPhase;
31+
buildActionMask = 2147483647;
32+
files = (
33+
);
34+
runOnlyForDeploymentPostprocessing = 0;
35+
};
36+
/* End PBXFrameworksBuildPhase section */
37+
38+
/* Begin PBXGroup section */
39+
531AABE4193D204000E16ED6 = {
40+
isa = PBXGroup;
41+
children = (
42+
535B260D1F3E0F7F006A5EF0 /* ReadMe.md */,
43+
531AABEF193D204000E16ED6 /* PageControl */,
44+
531AABEE193D204000E16ED6 /* Products */,
45+
);
46+
sourceTree = "<group>";
47+
};
48+
531AABEE193D204000E16ED6 /* Products */ = {
49+
isa = PBXGroup;
50+
children = (
51+
531AABED193D204000E16ED6 /* PageControl.app */,
52+
);
53+
name = Products;
54+
sourceTree = "<group>";
55+
};
56+
531AABEF193D204000E16ED6 /* PageControl */ = {
57+
isa = PBXGroup;
58+
children = (
59+
53F37B381F3B5F8000976FC6 /* AppDelegate.swift */,
60+
53F37B3B1F3B5F8000976FC6 /* ViewController.swift */,
61+
53F37B391F3B5F8000976FC6 /* Images.xcassets */,
62+
531AABF0193D204000E16ED6 /* Supporting Files */,
63+
);
64+
name = PageControl;
65+
sourceTree = "<group>";
66+
};
67+
531AABF0193D204000E16ED6 /* Supporting Files */ = {
68+
isa = PBXGroup;
69+
children = (
70+
53F37B3A1F3B5F8000976FC6 /* Info.plist */,
71+
53F37B401F3B5F9100976FC6 /* LaunchScreen.storyboard */,
72+
53F37B421F3B5F9100976FC6 /* Main.storyboard */,
73+
);
74+
name = "Supporting Files";
75+
sourceTree = "<group>";
76+
};
77+
/* End PBXGroup section */
78+
79+
/* Begin PBXNativeTarget section */
80+
531AABEC193D204000E16ED6 /* PageControl */ = {
81+
isa = PBXNativeTarget;
82+
buildConfigurationList = 531AAC09193D204000E16ED6 /* Build configuration list for PBXNativeTarget "PageControl" */;
83+
buildPhases = (
84+
531AABE9193D204000E16ED6 /* Sources */,
85+
531AABEA193D204000E16ED6 /* Frameworks */,
86+
531AABEB193D204000E16ED6 /* Resources */,
87+
);
88+
buildRules = (
89+
);
90+
dependencies = (
91+
);
92+
name = PageControl;
93+
productName = SingleView;
94+
productReference = 531AABED193D204000E16ED6 /* PageControl.app */;
95+
productType = "com.apple.product-type.application";
96+
};
97+
/* End PBXNativeTarget section */
98+
99+
/* Begin PBXProject section */
100+
531AABE5193D204000E16ED6 /* Project object */ = {
101+
isa = PBXProject;
102+
attributes = {
103+
LastSwiftUpdateCheck = 0700;
104+
LastUpgradeCheck = 0900;
105+
ORGANIZATIONNAME = "Apple, Inc.";
106+
TargetAttributes = {
107+
531AABEC193D204000E16ED6 = {
108+
CreatedOnToolsVersion = 6.0;
109+
LastSwiftMigration = 0900;
110+
};
111+
};
112+
};
113+
buildConfigurationList = 531AABE8193D204000E16ED6 /* Build configuration list for PBXProject "PageControl" */;
114+
compatibilityVersion = "Xcode 3.2";
115+
developmentRegion = English;
116+
hasScannedForEncodings = 0;
117+
knownRegions = (
118+
en,
119+
Base,
120+
);
121+
mainGroup = 531AABE4193D204000E16ED6;
122+
productRefGroup = 531AABEE193D204000E16ED6 /* Products */;
123+
projectDirPath = "";
124+
projectRoot = "";
125+
targets = (
126+
531AABEC193D204000E16ED6 /* PageControl */,
127+
);
128+
};
129+
/* End PBXProject section */
130+
131+
/* Begin PBXResourcesBuildPhase section */
132+
531AABEB193D204000E16ED6 /* Resources */ = {
133+
isa = PBXResourcesBuildPhase;
134+
buildActionMask = 2147483647;
135+
files = (
136+
53F37B451F3B5F9100976FC6 /* Main.storyboard in Resources */,
137+
53F37B3D1F3B5F8000976FC6 /* Images.xcassets in Resources */,
138+
53F37B441F3B5F9100976FC6 /* LaunchScreen.storyboard in Resources */,
139+
);
140+
runOnlyForDeploymentPostprocessing = 0;
141+
};
142+
/* End PBXResourcesBuildPhase section */
143+
144+
/* Begin PBXSourcesBuildPhase section */
145+
531AABE9193D204000E16ED6 /* Sources */ = {
146+
isa = PBXSourcesBuildPhase;
147+
buildActionMask = 2147483647;
148+
files = (
149+
53F37B3F1F3B5F8000976FC6 /* ViewController.swift in Sources */,
150+
53F37B3C1F3B5F8000976FC6 /* AppDelegate.swift in Sources */,
151+
);
152+
runOnlyForDeploymentPostprocessing = 0;
153+
};
154+
/* End PBXSourcesBuildPhase section */
155+
156+
/* Begin PBXVariantGroup section */
157+
53F37B401F3B5F9100976FC6 /* LaunchScreen.storyboard */ = {
158+
isa = PBXVariantGroup;
159+
children = (
160+
53F37B411F3B5F9100976FC6 /* Base */,
161+
);
162+
name = LaunchScreen.storyboard;
163+
sourceTree = "<group>";
164+
};
165+
53F37B421F3B5F9100976FC6 /* Main.storyboard */ = {
166+
isa = PBXVariantGroup;
167+
children = (
168+
53F37B431F3B5F9100976FC6 /* Base */,
169+
);
170+
name = Main.storyboard;
171+
sourceTree = "<group>";
172+
};
173+
/* End PBXVariantGroup section */
174+
175+
/* Begin XCBuildConfiguration section */
176+
531AAC07193D204000E16ED6 /* Debug */ = {
177+
isa = XCBuildConfiguration;
178+
buildSettings = {
179+
ALWAYS_SEARCH_USER_PATHS = NO;
180+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
181+
CLANG_CXX_LIBRARY = "libc++";
182+
CLANG_ENABLE_MODULES = YES;
183+
CLANG_ENABLE_OBJC_ARC = YES;
184+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
185+
CLANG_WARN_BOOL_CONVERSION = YES;
186+
CLANG_WARN_COMMA = YES;
187+
CLANG_WARN_CONSTANT_CONVERSION = YES;
188+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
189+
CLANG_WARN_EMPTY_BODY = YES;
190+
CLANG_WARN_ENUM_CONVERSION = YES;
191+
CLANG_WARN_INFINITE_RECURSION = YES;
192+
CLANG_WARN_INT_CONVERSION = YES;
193+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
194+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
195+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
196+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
197+
CLANG_WARN_STRICT_PROTOTYPES = YES;
198+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
199+
CLANG_WARN_UNREACHABLE_CODE = YES;
200+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
201+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
202+
COPY_PHASE_STRIP = NO;
203+
ENABLE_STRICT_OBJC_MSGSEND = YES;
204+
ENABLE_TESTABILITY = YES;
205+
GCC_C_LANGUAGE_STANDARD = gnu99;
206+
GCC_DYNAMIC_NO_PIC = NO;
207+
GCC_NO_COMMON_BLOCKS = YES;
208+
GCC_OPTIMIZATION_LEVEL = 0;
209+
GCC_PREPROCESSOR_DEFINITIONS = (
210+
"DEBUG=1",
211+
"$(inherited)",
212+
);
213+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
214+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
215+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
216+
GCC_WARN_UNDECLARED_SELECTOR = YES;
217+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
218+
GCC_WARN_UNUSED_FUNCTION = YES;
219+
GCC_WARN_UNUSED_VARIABLE = YES;
220+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
221+
METAL_ENABLE_DEBUG_INFO = YES;
222+
ONLY_ACTIVE_ARCH = YES;
223+
SDKROOT = iphoneos;
224+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
225+
TARGETED_DEVICE_FAMILY = "1,2";
226+
};
227+
name = Debug;
228+
};
229+
531AAC08193D204000E16ED6 /* Release */ = {
230+
isa = XCBuildConfiguration;
231+
buildSettings = {
232+
ALWAYS_SEARCH_USER_PATHS = NO;
233+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
234+
CLANG_CXX_LIBRARY = "libc++";
235+
CLANG_ENABLE_MODULES = YES;
236+
CLANG_ENABLE_OBJC_ARC = YES;
237+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
238+
CLANG_WARN_BOOL_CONVERSION = YES;
239+
CLANG_WARN_COMMA = YES;
240+
CLANG_WARN_CONSTANT_CONVERSION = YES;
241+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
242+
CLANG_WARN_EMPTY_BODY = YES;
243+
CLANG_WARN_ENUM_CONVERSION = YES;
244+
CLANG_WARN_INFINITE_RECURSION = YES;
245+
CLANG_WARN_INT_CONVERSION = YES;
246+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
247+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
248+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
249+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
250+
CLANG_WARN_STRICT_PROTOTYPES = YES;
251+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
252+
CLANG_WARN_UNREACHABLE_CODE = YES;
253+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
254+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
255+
COPY_PHASE_STRIP = YES;
256+
ENABLE_NS_ASSERTIONS = NO;
257+
ENABLE_STRICT_OBJC_MSGSEND = YES;
258+
GCC_C_LANGUAGE_STANDARD = gnu99;
259+
GCC_NO_COMMON_BLOCKS = YES;
260+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
261+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
262+
GCC_WARN_UNDECLARED_SELECTOR = YES;
263+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
264+
GCC_WARN_UNUSED_FUNCTION = YES;
265+
GCC_WARN_UNUSED_VARIABLE = YES;
266+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
267+
METAL_ENABLE_DEBUG_INFO = NO;
268+
SDKROOT = iphoneos;
269+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
270+
TARGETED_DEVICE_FAMILY = "1,2";
271+
VALIDATE_PRODUCT = YES;
272+
};
273+
name = Release;
274+
};
275+
531AAC0A193D204000E16ED6 /* Debug */ = {
276+
isa = XCBuildConfiguration;
277+
buildSettings = {
278+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
279+
CLANG_ENABLE_MODULES = YES;
280+
DEVELOPMENT_TEAM = "";
281+
INFOPLIST_FILE = "$(SRCROOT)/PageControl/Info.plist";
282+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
283+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
284+
PRODUCT_BUNDLE_IDENTIFIER = "com.example.apple-samplecode.${PRODUCT_NAME:rfc1034identifier}";
285+
PRODUCT_NAME = "$(TARGET_NAME)";
286+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
287+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
288+
SWIFT_VERSION = 4.0;
289+
TARGETED_DEVICE_FAMILY = "1,2";
290+
};
291+
name = Debug;
292+
};
293+
531AAC0B193D204000E16ED6 /* Release */ = {
294+
isa = XCBuildConfiguration;
295+
buildSettings = {
296+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
297+
CLANG_ENABLE_MODULES = YES;
298+
DEVELOPMENT_TEAM = "";
299+
INFOPLIST_FILE = "$(SRCROOT)/PageControl/Info.plist";
300+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
301+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
302+
PRODUCT_BUNDLE_IDENTIFIER = "com.example.apple-samplecode.${PRODUCT_NAME:rfc1034identifier}";
303+
PRODUCT_NAME = "$(TARGET_NAME)";
304+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
305+
SWIFT_VERSION = 4.0;
306+
TARGETED_DEVICE_FAMILY = "1,2";
307+
};
308+
name = Release;
309+
};
310+
/* End XCBuildConfiguration section */
311+
312+
/* Begin XCConfigurationList section */
313+
531AABE8193D204000E16ED6 /* Build configuration list for PBXProject "PageControl" */ = {
314+
isa = XCConfigurationList;
315+
buildConfigurations = (
316+
531AAC07193D204000E16ED6 /* Debug */,
317+
531AAC08193D204000E16ED6 /* Release */,
318+
);
319+
defaultConfigurationIsVisible = 0;
320+
defaultConfigurationName = Release;
321+
};
322+
531AAC09193D204000E16ED6 /* Build configuration list for PBXNativeTarget "PageControl" */ = {
323+
isa = XCConfigurationList;
324+
buildConfigurations = (
325+
531AAC0A193D204000E16ED6 /* Debug */,
326+
531AAC0B193D204000E16ED6 /* Release */,
327+
);
328+
defaultConfigurationIsVisible = 0;
329+
defaultConfigurationName = Release;
330+
};
331+
/* End XCConfigurationList section */
332+
};
333+
rootObject = 531AABE5193D204000E16ED6 /* Project object */;
334+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Copyright (C) 2017 Apple Inc. All Rights Reserved.
3+
See LICENSE.txt for this sample’s licensing information
4+
5+
Abstract:
6+
The application-specific delegate class.
7+
*/
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
var window: UIWindow?
14+
15+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
16+
// Override point for customization after application launch.
17+
return true
18+
}
19+
}
20+

0 commit comments

Comments
 (0)