Skip to content

Commit f4d3340

Browse files
committed
PhotoPicker: Using UIImagePickerController to Select Pictures and Take Photos: Version 4.2, 2018-01-11
Updated to iOS 11 SDK, converted to Swift, storyboard changes to support iPhone X. PhotoPicker demonstrates choosing images from the photo library, take a picture with the camera, and customizing the camera view. This is done by using UIImagePickerController. The chosen image or camera photo is displayed in a UIImageView. To customize the camera's interface, this sample shows how to use an overlay view. With this overlay view it gives you the ability to customize the UI as you take a picture. Among the custom features of the camera is to take a single picture, timed picture, or repeated pictures like a camera with a fast shutter speed. Timed and shutter speed camera shots are done using the NSTimer class. Signed-off-by: Liu Lantao <[email protected]>
1 parent ff28a56 commit f4d3340

File tree

12 files changed

+1070
-0
lines changed

12 files changed

+1070
-0
lines changed

PhotoPicker/LICENSE.txt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Sample code project: PhotoPicker: Using UIImagePickerController to Select Pictures and Take Photos
2+
Version: 4.2
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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
5320B8571AFD59C0008854DF /* APLAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5320B8561AFD59C0008854DF /* APLAppDelegate.swift */; };
11+
5320B8591AFD59C0008854DF /* APLViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5320B8581AFD59C0008854DF /* APLViewController.swift */; };
12+
53A0CE4B1FBCC15700083090 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 53A0CE471FBCC15600083090 /* LaunchScreen.storyboard */; };
13+
53A0CE4C1FBCC15700083090 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 53A0CE491FBCC15700083090 /* Main.storyboard */; };
14+
53A851371FE1D2B90003FE24 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 53A851361FE1D2B90003FE24 /* Images.xcassets */; };
15+
53A8513A1FE1D3460003FE24 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 53A851381FE1D3460003FE24 /* InfoPlist.strings */; };
16+
/* End PBXBuildFile section */
17+
18+
/* Begin PBXFileReference section */
19+
5320B8511AFD59C0008854DF /* PhotoPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PhotoPicker.app; sourceTree = BUILT_PRODUCTS_DIR; };
20+
5320B8551AFD59C0008854DF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
21+
5320B8561AFD59C0008854DF /* APLAppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APLAppDelegate.swift; sourceTree = "<group>"; };
22+
5320B8581AFD59C0008854DF /* APLViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APLViewController.swift; sourceTree = "<group>"; };
23+
5343B7E81FE1A12B00EA3B2E /* ReadMe.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = ReadMe.md; sourceTree = "<group>"; };
24+
53A0CE481FBCC15600083090 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
25+
53A0CE4A1FBCC15700083090 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
26+
53A851361FE1D2B90003FE24 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
27+
53A851391FE1D3460003FE24 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
28+
/* End PBXFileReference section */
29+
30+
/* Begin PBXFrameworksBuildPhase section */
31+
5320B84E1AFD59C0008854DF /* Frameworks */ = {
32+
isa = PBXFrameworksBuildPhase;
33+
buildActionMask = 2147483647;
34+
files = (
35+
);
36+
runOnlyForDeploymentPostprocessing = 0;
37+
};
38+
/* End PBXFrameworksBuildPhase section */
39+
40+
/* Begin PBXGroup section */
41+
5320B8481AFD59C0008854DF = {
42+
isa = PBXGroup;
43+
children = (
44+
5343B7E81FE1A12B00EA3B2E /* ReadMe.md */,
45+
5320B8531AFD59C0008854DF /* PhotoPicker */,
46+
5320B8521AFD59C0008854DF /* Products */,
47+
);
48+
sourceTree = "<group>";
49+
};
50+
5320B8521AFD59C0008854DF /* Products */ = {
51+
isa = PBXGroup;
52+
children = (
53+
5320B8511AFD59C0008854DF /* PhotoPicker.app */,
54+
);
55+
name = Products;
56+
sourceTree = "<group>";
57+
};
58+
5320B8531AFD59C0008854DF /* PhotoPicker */ = {
59+
isa = PBXGroup;
60+
children = (
61+
5320B8561AFD59C0008854DF /* APLAppDelegate.swift */,
62+
5320B8581AFD59C0008854DF /* APLViewController.swift */,
63+
5320B8541AFD59C0008854DF /* Supporting Files */,
64+
);
65+
path = PhotoPicker;
66+
sourceTree = "<group>";
67+
};
68+
5320B8541AFD59C0008854DF /* Supporting Files */ = {
69+
isa = PBXGroup;
70+
children = (
71+
53A0CE471FBCC15600083090 /* LaunchScreen.storyboard */,
72+
53A0CE491FBCC15700083090 /* Main.storyboard */,
73+
5320B8551AFD59C0008854DF /* Info.plist */,
74+
53A851381FE1D3460003FE24 /* InfoPlist.strings */,
75+
53A851361FE1D2B90003FE24 /* Images.xcassets */,
76+
);
77+
name = "Supporting Files";
78+
sourceTree = "<group>";
79+
};
80+
/* End PBXGroup section */
81+
82+
/* Begin PBXNativeTarget section */
83+
5320B8501AFD59C0008854DF /* PhotoPicker */ = {
84+
isa = PBXNativeTarget;
85+
buildConfigurationList = 5320B8721AFD59C0008854DF /* Build configuration list for PBXNativeTarget "PhotoPicker" */;
86+
buildPhases = (
87+
5320B84D1AFD59C0008854DF /* Sources */,
88+
5320B84E1AFD59C0008854DF /* Frameworks */,
89+
5320B84F1AFD59C0008854DF /* Resources */,
90+
);
91+
buildRules = (
92+
);
93+
dependencies = (
94+
);
95+
name = PhotoPicker;
96+
productName = SimpleApp;
97+
productReference = 5320B8511AFD59C0008854DF /* PhotoPicker.app */;
98+
productType = "com.apple.product-type.application";
99+
};
100+
/* End PBXNativeTarget section */
101+
102+
/* Begin PBXProject section */
103+
5320B8491AFD59C0008854DF /* Project object */ = {
104+
isa = PBXProject;
105+
attributes = {
106+
LastSwiftMigration = 0700;
107+
LastSwiftUpdateCheck = 0700;
108+
LastUpgradeCheck = 0900;
109+
ORGANIZATIONNAME = "";
110+
TargetAttributes = {
111+
5320B8501AFD59C0008854DF = {
112+
CreatedOnToolsVersion = 6.3.1;
113+
DevelopmentTeam = V7M23Q5387;
114+
LastSwiftMigration = 0900;
115+
};
116+
};
117+
};
118+
buildConfigurationList = 5320B84C1AFD59C0008854DF /* Build configuration list for PBXProject "PhotoPicker" */;
119+
compatibilityVersion = "Xcode 3.2";
120+
developmentRegion = English;
121+
hasScannedForEncodings = 0;
122+
knownRegions = (
123+
en,
124+
Base,
125+
);
126+
mainGroup = 5320B8481AFD59C0008854DF;
127+
productRefGroup = 5320B8521AFD59C0008854DF /* Products */;
128+
projectDirPath = "";
129+
projectRoot = "";
130+
targets = (
131+
5320B8501AFD59C0008854DF /* PhotoPicker */,
132+
);
133+
};
134+
/* End PBXProject section */
135+
136+
/* Begin PBXResourcesBuildPhase section */
137+
5320B84F1AFD59C0008854DF /* Resources */ = {
138+
isa = PBXResourcesBuildPhase;
139+
buildActionMask = 2147483647;
140+
files = (
141+
53A851371FE1D2B90003FE24 /* Images.xcassets in Resources */,
142+
53A8513A1FE1D3460003FE24 /* InfoPlist.strings in Resources */,
143+
53A0CE4C1FBCC15700083090 /* Main.storyboard in Resources */,
144+
53A0CE4B1FBCC15700083090 /* LaunchScreen.storyboard in Resources */,
145+
);
146+
runOnlyForDeploymentPostprocessing = 0;
147+
};
148+
/* End PBXResourcesBuildPhase section */
149+
150+
/* Begin PBXSourcesBuildPhase section */
151+
5320B84D1AFD59C0008854DF /* Sources */ = {
152+
isa = PBXSourcesBuildPhase;
153+
buildActionMask = 2147483647;
154+
files = (
155+
5320B8591AFD59C0008854DF /* APLViewController.swift in Sources */,
156+
5320B8571AFD59C0008854DF /* APLAppDelegate.swift in Sources */,
157+
);
158+
runOnlyForDeploymentPostprocessing = 0;
159+
};
160+
/* End PBXSourcesBuildPhase section */
161+
162+
/* Begin PBXVariantGroup section */
163+
53A0CE471FBCC15600083090 /* LaunchScreen.storyboard */ = {
164+
isa = PBXVariantGroup;
165+
children = (
166+
53A0CE481FBCC15600083090 /* Base */,
167+
);
168+
name = LaunchScreen.storyboard;
169+
sourceTree = "<group>";
170+
};
171+
53A0CE491FBCC15700083090 /* Main.storyboard */ = {
172+
isa = PBXVariantGroup;
173+
children = (
174+
53A0CE4A1FBCC15700083090 /* Base */,
175+
);
176+
name = Main.storyboard;
177+
sourceTree = "<group>";
178+
};
179+
53A851381FE1D3460003FE24 /* InfoPlist.strings */ = {
180+
isa = PBXVariantGroup;
181+
children = (
182+
53A851391FE1D3460003FE24 /* en */,
183+
);
184+
name = InfoPlist.strings;
185+
sourceTree = "<group>";
186+
};
187+
/* End PBXVariantGroup section */
188+
189+
/* Begin XCBuildConfiguration section */
190+
5320B8701AFD59C0008854DF /* Debug */ = {
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_BLOCK_CAPTURE_AUTORELEASING = YES;
199+
CLANG_WARN_BOOL_CONVERSION = YES;
200+
CLANG_WARN_COMMA = YES;
201+
CLANG_WARN_CONSTANT_CONVERSION = YES;
202+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
203+
CLANG_WARN_EMPTY_BODY = YES;
204+
CLANG_WARN_ENUM_CONVERSION = YES;
205+
CLANG_WARN_INFINITE_RECURSION = YES;
206+
CLANG_WARN_INT_CONVERSION = YES;
207+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
208+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
209+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
210+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
211+
CLANG_WARN_STRICT_PROTOTYPES = YES;
212+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
213+
CLANG_WARN_UNREACHABLE_CODE = YES;
214+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
215+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
216+
COPY_PHASE_STRIP = NO;
217+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
218+
ENABLE_STRICT_OBJC_MSGSEND = YES;
219+
ENABLE_TESTABILITY = YES;
220+
GCC_C_LANGUAGE_STANDARD = gnu99;
221+
GCC_DYNAMIC_NO_PIC = NO;
222+
GCC_NO_COMMON_BLOCKS = YES;
223+
GCC_OPTIMIZATION_LEVEL = 0;
224+
GCC_PREPROCESSOR_DEFINITIONS = (
225+
"DEBUG=1",
226+
"$(inherited)",
227+
);
228+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
229+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
230+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
231+
GCC_WARN_UNDECLARED_SELECTOR = YES;
232+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
233+
GCC_WARN_UNUSED_FUNCTION = YES;
234+
GCC_WARN_UNUSED_VARIABLE = YES;
235+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
236+
MTL_ENABLE_DEBUG_INFO = YES;
237+
ONLY_ACTIVE_ARCH = YES;
238+
SDKROOT = iphoneos;
239+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
240+
};
241+
name = Debug;
242+
};
243+
5320B8711AFD59C0008854DF /* Release */ = {
244+
isa = XCBuildConfiguration;
245+
buildSettings = {
246+
ALWAYS_SEARCH_USER_PATHS = NO;
247+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
248+
CLANG_CXX_LIBRARY = "libc++";
249+
CLANG_ENABLE_MODULES = YES;
250+
CLANG_ENABLE_OBJC_ARC = YES;
251+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
252+
CLANG_WARN_BOOL_CONVERSION = YES;
253+
CLANG_WARN_COMMA = YES;
254+
CLANG_WARN_CONSTANT_CONVERSION = YES;
255+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
256+
CLANG_WARN_EMPTY_BODY = YES;
257+
CLANG_WARN_ENUM_CONVERSION = YES;
258+
CLANG_WARN_INFINITE_RECURSION = YES;
259+
CLANG_WARN_INT_CONVERSION = YES;
260+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
261+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
262+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
263+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
264+
CLANG_WARN_STRICT_PROTOTYPES = YES;
265+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
266+
CLANG_WARN_UNREACHABLE_CODE = YES;
267+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
268+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
269+
COPY_PHASE_STRIP = NO;
270+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
271+
ENABLE_NS_ASSERTIONS = NO;
272+
ENABLE_STRICT_OBJC_MSGSEND = YES;
273+
GCC_C_LANGUAGE_STANDARD = gnu99;
274+
GCC_NO_COMMON_BLOCKS = YES;
275+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
276+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
277+
GCC_WARN_UNDECLARED_SELECTOR = YES;
278+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
279+
GCC_WARN_UNUSED_FUNCTION = YES;
280+
GCC_WARN_UNUSED_VARIABLE = YES;
281+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
282+
MTL_ENABLE_DEBUG_INFO = NO;
283+
SDKROOT = iphoneos;
284+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
285+
VALIDATE_PRODUCT = YES;
286+
};
287+
name = Release;
288+
};
289+
5320B8731AFD59C0008854DF /* Debug */ = {
290+
isa = XCBuildConfiguration;
291+
buildSettings = {
292+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
293+
DEVELOPMENT_TEAM = V7M23Q5387;
294+
INFOPLIST_FILE = "$(SRCROOT)/PhotoPicker/Info.plist";
295+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
296+
PRODUCT_BUNDLE_IDENTIFIER = "com.example.apple-samplecode.PhotoPicker";
297+
PRODUCT_NAME = "$(TARGET_NAME)";
298+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
299+
SWIFT_VERSION = 4.0;
300+
TARGETED_DEVICE_FAMILY = "1,2";
301+
};
302+
name = Debug;
303+
};
304+
5320B8741AFD59C0008854DF /* Release */ = {
305+
isa = XCBuildConfiguration;
306+
buildSettings = {
307+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
308+
DEVELOPMENT_TEAM = V7M23Q5387;
309+
INFOPLIST_FILE = "$(SRCROOT)/PhotoPicker/Info.plist";
310+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
311+
PRODUCT_BUNDLE_IDENTIFIER = "com.example.apple-samplecode.PhotoPicker";
312+
PRODUCT_NAME = "$(TARGET_NAME)";
313+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
314+
SWIFT_VERSION = 4.0;
315+
TARGETED_DEVICE_FAMILY = "1,2";
316+
};
317+
name = Release;
318+
};
319+
/* End XCBuildConfiguration section */
320+
321+
/* Begin XCConfigurationList section */
322+
5320B84C1AFD59C0008854DF /* Build configuration list for PBXProject "PhotoPicker" */ = {
323+
isa = XCConfigurationList;
324+
buildConfigurations = (
325+
5320B8701AFD59C0008854DF /* Debug */,
326+
5320B8711AFD59C0008854DF /* Release */,
327+
);
328+
defaultConfigurationIsVisible = 0;
329+
defaultConfigurationName = Release;
330+
};
331+
5320B8721AFD59C0008854DF /* Build configuration list for PBXNativeTarget "PhotoPicker" */ = {
332+
isa = XCConfigurationList;
333+
buildConfigurations = (
334+
5320B8731AFD59C0008854DF /* Debug */,
335+
5320B8741AFD59C0008854DF /* Release */,
336+
);
337+
defaultConfigurationIsVisible = 0;
338+
defaultConfigurationName = Release;
339+
};
340+
/* End XCConfigurationList section */
341+
};
342+
rootObject = 5320B8491AFD59C0008854DF /* Project object */;
343+
}

0 commit comments

Comments
 (0)