Compare commits

..

123 Commits

Author SHA1 Message Date
Ricardo Torrão 22f3e5320e more Swift 3.0 changes 2016-09-16 15:05:26 +01:00
Ricardo Torrão 8f31fba846 Merge pull request #61 from dimohamdy/swift-3.0
update for Swift 3.0
2016-09-16 12:27:46 +01:00
dimohamdy 206bce0e94 update demo to support swift 3 2016-08-19 04:08:26 +03:00
dimohamdy 0267cc2664 support swift 3 2016-08-19 04:04:13 +03:00
Ricardo Torrão 389ec550b3 2.2.4 2016-07-06 14:35:54 +01:00
Ricardo Torrão c8605d523a add error checking 2016-07-06 14:34:01 +01:00
Ricardo Torrão 6ce822261d Update README.md 2016-07-06 14:07:51 +01:00
Ricardo Torrão c0c55be070 checks if an output can be added to the session (issue #49) 2016-07-06 12:58:28 +01:00
Ricardo Torrão b23f2ccbc4 fixes completition typos and suggests renamed functions 2016-07-06 11:55:53 +01:00
Ricardo Torrão 004876d34e Update README.md 2016-07-06 11:08:30 +01:00
Ricardo Torrão dd34c6468e Merge pull request #47 from SongJiaqiang/jq.fixbug
Use a most effective way to retrieve real interface orientation.
2016-07-06 11:05:43 +01:00
Joel Reis 33a0e2b1e4 2.2.3 2016-05-12 17:05:49 +01:00
Joel Reis 4639a1b661 fix zoom in StillImage Mode 2016-05-12 17:02:55 +01:00
Jiaqiang e598b71173 Use a most effective way to retrieve real interface orientation.
UIDevice.currentDevice().orientation returns the orientation of device.
UIApplication.sharedApplication().statusBarOrientation returns the
orientation of UI interface.
For example.
1. check out Portrait only in info.plist.
2. Setup shouldRespondToOrientationChanges=false.
3. Launch app with LandscapeLeft.
Intent: orientation is .Portrait
Actually: orientation is .LandscapeLeft
2016-04-19 17:59:55 +08:00
Ricardo Torrão a12d5e28e9 Update README.md 2016-04-04 22:24:13 +01:00
Daniel Pereira 68e289a755 minor changes to swift 2.2 2016-03-30 15:28:36 +01:00
Daniel Pereira c875a0c03d refactor to more idiomatic swift 2016-03-30 15:26:03 +01:00
Daniel Pereira cf0e3759b4 changed weak self reference to unowned on cameraPictureWithCompletion and cameraPictureDataWithCompletion 2016-03-30 14:20:08 +01:00
Daniel Pereira bfb31dd14b Merge pull request #41 from SongJiaqiang/fork.capturePictureCallback
Add a capture picture callback to pass on image data
2016-03-30 12:15:57 +01:00
jiaqiang c0a95613f1 Add a capture picture callback to pass on image data
Sometimes, user want to store the picture by the other ways, such as a
new album, sand disk and so on. Or cutting, compounding, adding filter.
2016-03-28 23:14:05 +08:00
Ricardo Torrão 935e352460 v2.2.2 2016-03-07 19:02:57 +00:00
Ricardo Torrão 48450d49b6 Minor changes 2016-03-07 19:00:15 +00:00
Ricardo Torrão 9aaec6ce96 Add link to versions 2016-03-07 18:58:45 +00:00
Ricardo Torrão fdb9d48a41 Minor changes 2016-03-07 18:49:49 +00:00
Ricardo Torrão 818e50d6ee Add CHANGELOG 2016-03-07 18:36:22 +00:00
Ricardo Torrão 95d2830e8a v2.2.1 2016-03-02 10:31:04 +00:00
Ricardo Torrão 57a66bc7a9 Add target to package.swift 2016-03-02 10:22:44 +00:00
Ricardo Torrão 21c85f2e4d Change minor version on package dependency 2016-03-02 10:17:06 +00:00
Ricardo Torrão 1e6ff8f83a Minor changes 2016-03-02 10:15:48 +00:00
Ricardo Torrão ab500cbb13 Minor changes to the README 2016-03-02 10:12:45 +00:00
Ricardo Torrão fb22e0478f Initial support for Swift Package Manager 2016-03-02 10:11:23 +00:00
Ricardo Torrão 8fb105dec2 Update README.md 2016-02-22 22:54:03 +00:00
Ricardo Torrão 6cf2f90fff Update README.md
Add zoom to the Readme
2016-02-22 22:46:05 +00:00
Ricardo Torrão ff11c03832 Minor fixes and improvements 2016-02-17 10:15:49 +00:00
Ricardo Torrão 5a7e61851b Update README.md 2016-02-15 13:56:25 +00:00
Ricardo Torrão a581855d5f v2.2.0 2016-02-15 13:40:51 +00:00
Ricardo Torrão e55c892898 Zoom improvements 2016-02-15 12:16:12 +00:00
Ricardo Torrão d85f5afc7c Merge pull request #36 from GiantBike/tomcatzoom
Fixed spelling of embeddingview. Also added zoom to the screen.
2016-02-15 12:06:35 +00:00
Tom 2500e1b231 Fixed spelling of embeddingview. Also added zoom to the screen. 2016-01-28 18:11:30 +00:00
Natalia Terlecka 6c4094cac6 Ready updated. 2016-01-08 12:06:40 +01:00
Natalia Terlecka 3df05957a5 v2.1.3 2016-01-08 11:57:42 +01:00
Natalia Terlecka 745a1df62f No sound in video more than 10 seconds fixed. 2016-01-08 11:55:30 +01:00
Natalia Terlecka 8a818c1b96 NewCameraOutputMode not passed during init bug fixed. 2016-01-08 11:11:06 +01:00
Natalia Terlecka 5ded48c44c v2.1.2 2015-12-24 10:01:20 +01:00
Natalia Terlecka 050f42bbd9 cameraIsReady property and addPreviewLayerToView competition block. 2015-12-24 09:57:14 +01:00
Natalia Terlecka a10dc6338c v2.1.1 2015-12-11 11:38:57 +00:00
Natalia Terlecka ddffdac96e Start and stop following device orientation notification resumed. 2015-12-11 11:37:45 +00:00
Natalia 334ce5b7a5 Merge pull request #26 from aukaost/master
allow disabling of handling device orientation changes
2015-12-11 11:26:28 +00:00
Simon Leonhardt 48c92640c5 fix typo 2015-12-07 23:45:36 +00:00
Simon Leonhardt f0340013cc allow disabling of responding to device orientation changes 2015-12-07 23:44:41 +00:00
Natalia Terlecka bf9add31dd Readme updated. 2015-11-20 09:19:39 +00:00
Natalia Terlecka bc32517b69 v2.1 2015-11-20 09:09:08 +00:00
Natalia Terlecka bb3c734e1a Shared instance removed. 2015-11-18 10:06:18 +00:00
Natalia Terlecka 9d16f88bc8 _cameraOutputMode removed. 2015-11-18 09:31:37 +00:00
Natalia Terlecka 2528209921 _cameraOutputQuality removed. 2015-11-18 09:20:33 +00:00
Natalia Terlecka ddd1d78d3e _flashMode property removed. 2015-11-18 09:17:19 +00:00
Natalia Terlecka 783e47033d _cameraDevice device private property removed. 2015-11-18 09:13:21 +00:00
Natalia Terlecka 5c85fdf276 Unnecessary self's removed. 2015-11-18 08:39:19 +00:00
Natalia Terlecka 8427b18ef5 Code formatting updated. Lazy front, back and mic initialization. 2015-11-18 08:28:25 +00:00
Natalia Terlecka 0c0d7a0e0d recordedDuration and recordedFileSize 2015-11-18 08:04:13 +00:00
Natalia Terlecka 5b709a0174 Podfile bug fix 2015-11-18 07:39:20 +00:00
Natalia Terlecka fb81adb869 v2.0.2 2015-11-17 09:18:11 +00:00
Natalia 05e6f145e1 Merge pull request #21 from jasonlagaac/master
Fixed iOS 9.0.1 bug
2015-11-17 09:08:52 +00:00
Jason Lagaac db9c936300 Fixed iOS 9.0.1 bug 2015-09-30 15:58:36 +10:00
Natalia Terlecka c3634300ce Version 2.0.1 2015-09-17 09:28:11 +01:00
Natalia Terlecka 151637eb32 Syntax updated. 2015-09-10 10:26:52 +01:00
Natalia Terlecka ee971a0a59 Version 2.0.0 2015-07-30 14:16:20 +01:00
Natalia Terlecka 68858dfb4b Syntax updated for Swift 2.0 2015-07-30 14:04:15 +01:00
miguelcampiao 0c0a90fe17 version 1.0.14, updated podspec 2015-07-17 15:54:04 +01:00
miguelcampiao 3ca231ed25 Updated README.md to reflect changes on the showErrorBlock method 2015-07-15 16:40:37 +01:00
miguelcampiao 0507f72f11 Adds example of usage of the UIAlertController to show error messages to the user. 2015-07-15 15:07:12 +01:00
Natalia d666ab665b Merge pull request #13 from PTEz/small_fixes
Small fixes
2015-07-06 22:45:05 +01:00
利辺羅 1854061a8e Add proper Swift pragma marks 2015-06-29 12:44:32 -04:00
利辺羅 5a643853e5 Add a proper .gitignore 2015-06-29 12:44:03 -04:00
Natalia 7cc218f385 Merge pull request #11 from aukaost/patch-1
fix typo
2015-05-18 09:25:16 +01:00
Simon 2618a8df95 fix typo 2015-05-17 15:56:14 +00:00
Natalia 9e2249197f Merge pull request #10 from agiletalk/master
Update for Carthage.
2015-05-15 08:54:52 +01:00
chanju Jeon 898d7cb571 Reset the default settings.
So that carthage can build without fixing any error.
2015-05-15 01:42:58 +09:00
Natalia Terlecka d367d94bea Version 1.0.13 2015-05-12 10:27:20 +01:00
Natalia Terlecka 7b16276fbb Merge branch 'lexrus-master' 2015-05-12 09:39:33 +01:00
Lex Tang 9b2d0cbf13 Now we can install this lib with Carthage. 2015-04-09 17:19:36 +08:00
Lex Tang 2d6c7be2b1 Reset the default settings.
So that every can compile without fixing any error.
2015-04-09 16:44:16 +08:00
Lex Tang ad2cec3e80 Update for Swift 1.2. 2015-04-09 16:42:50 +08:00
Natalia Terlecka 19074490ac Has flash property. 2015-03-24 10:48:20 +00:00
Natalia Terlecka 89105cd142 Quality setting updated. Permissions fixes. 2015-03-23 15:03:19 +00:00
Natalia Terlecka 8d1cb4afec Version 1.0.12 2015-03-23 09:33:37 +00:00
Natalia Terlecka 60e95a75fa Torch is set to correct state according to the current flash mode. 2015-03-23 09:31:28 +00:00
Natalia Terlecka 27194c99a9 Incrementing flash mode function. 2015-03-20 14:36:35 +00:00
Natalia Terlecka b6025c0faa Content localised. 2015-03-20 14:00:32 +00:00
Natalia Terlecka 5664f6b038 Readme updated. 2015-03-20 12:06:19 +00:00
Natalia Terlecka 41bcc315fe Version 1.0.11 2015-03-20 12:03:48 +00:00
Natalia Terlecka b0ebfcd94b New property to determine if you want the user to be asked about camera permissions automatically or manually. 2015-03-20 11:59:51 +00:00
Natalia Terlecka 0ea8751297 Error handling in capture competition blocks. Permissions fixes. 2015-03-20 10:46:01 +00:00
Natalia Terlecka 2a86fe5140 Podspec updated. 2015-03-19 10:55:30 +00:00
Natalia Terlecka 5def8cb543 Camera state returned when adding the preview layer. 2015-03-19 10:54:23 +00:00
Natalia Terlecka 302cae8b46 Readme updated. 2015-03-10 11:40:12 +00:00
Natalia Terlecka 9fc889a748 Readme updated. 2015-03-10 10:41:06 +00:00
Natalia Terlecka cfc19af21d Podspec error fix. 2015-03-10 10:39:15 +00:00
Natalia Terlecka 43910bafc0 Version 1.0.9 2015-03-06 17:48:26 +00:00
Natalia Terlecka eea00d4499 CameraManager class mande public. 2015-03-06 17:47:02 +00:00
Natalia Terlecka 258984c6de Merge branch 'master' of https://github.com/imaginary-cloud/CameraManager 2015-02-24 17:17:54 +00:00
Natalia Terlecka 2c52caa865 Code refactoring. 2015-02-24 17:17:40 +00:00
Natalia ed5c1ce95c Merge pull request #7 from davidy/master
fixed wrong orientation when camera preview starts in landscape mode
2015-02-18 09:57:11 +00:00
David Yun 118d1a66d3 fixed wrong orientation when camera preview starts in landscape mode 2015-02-16 11:26:42 -08:00
nelanelanela 31f57cb03c New version 1.0.8 2015-01-13 16:59:06 +00:00
nelanelanela 76c1e49db8 Bug fixes. 2015-01-13 16:57:06 +00:00
nelanelanela c6ce889f58 "When you stop and resume capture session, orientation detection doesn't work anymore" issue fixed. 2015-01-13 15:22:23 +00:00
nelanelanela ff3b954ed8 Crash when trying to capture a still image fixed. 2015-01-13 15:04:42 +00:00
Natalia c97f7807f4 Merge pull request #2 from davidortinau/master
changing to output mode using mic was never initializing the mic due to ...
2014-11-07 14:12:02 +00:00
David Ortinau ed8d3ff3f8 changing to output mode using mic was never initializing the mic due to evaluating the current mode instead of the new mode. Switched variables and now we can record audio. 2014-11-05 14:50:37 -06:00
nelanelanela dd52b8d186 New version compatible with Xcode 6.1 2014-10-30 10:39:48 +00:00
Natalia 420d74b51d Merge pull request #1 from davidortinau/master
Swift syntax updates to resolve compile errors (6.1 6A1052d)
2014-10-30 10:36:23 +00:00
David Ortinau aeb9daab30 Swift syntax updates to resolve compile errors (6.1 6A1052d) 2014-10-29 14:25:46 -05:00
nelanelanela ebd0295a79 Readme updated 2014-10-28 10:47:41 +00:00
nelanelanela e2108b5f5e typo fixed 2014-10-28 10:45:08 +00:00
nelanelanela 4c8f85142c New version 1.0.6 2014-10-28 10:26:56 +00:00
nelanelanela d0d3434d87 Video orientation change fixed 2014-10-28 10:23:24 +00:00
nelanelanela 7388c0cc87 Valid capture session check. 2014-10-23 17:52:34 +01:00
nelanelanela 619fb174f6 Podspec updated. 2014-10-22 12:51:37 +01:00
nelanelanela d09325e792 New version 2014-10-22 12:49:48 +01:00
nelanelanela 229c66aa72 Orientation observers added only as needed. 2014-10-21 11:40:48 +01:00
nelanelanela 99d6df9f8d Pdspec updated. 2014-10-21 11:35:01 +01:00
nelanelanela e98520ad37 Camera lifcycle enhenced. 2014-10-21 09:32:05 +01:00
23 changed files with 2609 additions and 658 deletions

43
.gitignore vendored Normal file
View File

@ -0,0 +1,43 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint
## Obj-C/Swift specific
*.hmap
*.ipa
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build

214
CHANGELOG.md Normal file
View File

@ -0,0 +1,214 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [3.0.0](https://github.com/imaginary-cloud/CameraManager/tree/3.0.0) - 2016-09-16
### Changed
- Syntax update for Swift 3.0.
## [2.2.4](https://github.com/imaginary-cloud/CameraManager/tree/2.2.4) - 2016-07-06
### Added
- Add error checking.
### Changed
- Fixes completion typos and suggests renamed functions.
## [2.2.3](https://github.com/imaginary-cloud/CameraManager/tree/2.2.3) - 2016-05-12
### Changed
- Fixed zoom in StillImage Mode.
- Minor refactoring
## [2.2.2](https://github.com/imaginary-cloud/CameraManager/tree/2.2.2) - 2016-03-07
### Added
- `CHANGELOG.md` file.
## [2.2.1](https://github.com/imaginary-cloud/CameraManager/tree/2.2.1) - 2016-03-02
### Added
- Initial support for the Swift Package Manager.
## [2.2.0](https://github.com/imaginary-cloud/CameraManager/tree/2.2.0) - 2016-02-19
### Added
- Zoom support.
### Changed
- Fixed spelling of `embeddingView`.
## [2.1.3](https://github.com/imaginary-cloud/CameraManager/tree/2.1.3) - 2016-01-08
### Changed
- No sound in video with more than 10 seconds fixed.
- Fixed `NewCameraOutputMode` not passed during init.
## [2.1.2](https://github.com/imaginary-cloud/CameraManager/tree/2.1.2) - 2015-12-24
### Added
- Property `cameraIsReady`.
- Completion block `addPreviewLayerToView`.
## [2.1.1](https://github.com/imaginary-cloud/CameraManager/tree/2.1.1) - 2015-12-11
### Added
- Ability to disable responding to device orientation changes.
## [2.1.0](https://github.com/imaginary-cloud/CameraManager/tree/2.1) - 2015-11-20
### Added
- Properties `recordedDuration` and `recordedFileSize`.
## [2.0.2](https://github.com/imaginary-cloud/CameraManager/tree/2.0.2) - 2015-11-17
### Fixed
- iOS 9.0.1 bug.
## [2.0.1](https://github.com/imaginary-cloud/CameraManager/tree/2.0.1) - 2015-09-17
### Changed
- Syntax updates.
## [2.0.0](https://github.com/imaginary-cloud/CameraManager/tree/2.0.0) - 2015-07-30
### Changed
- Syntax update for Swift 2.0.
## [1.0.14](https://github.com/imaginary-cloud/CameraManager/tree/1.0.14) - 2015-07-17
### Changed
- Small fixes.
## [1.0.13](https://github.com/imaginary-cloud/CameraManager/tree/1.0.13) - 2015-05-12
### Added
- Support for installing via Carthage.
- Property `hasFlash`.
### Changed
- Syntax update for Swift 1.2.
## [1.0.12](https://github.com/imaginary-cloud/CameraManager/tree/1.0.12) - 2015-03-23
### Added
- Incremental flash mode.
- Content localization.
### Changed
- Torch is set to correct state according to the current flash mode.
- `README.md` update.
## [1.0.11](https://github.com/imaginary-cloud/CameraManager/tree/1.0.11) - 2015-03-20
### Added
- Property `showAccessPermissionPopupAutomatically`, to determine if you want the user to be asked about camera permissions automatically or manually.
- Error handling in capture completion blocks.
## [1.0.10](https://github.com/imaginary-cloud/CameraManager/tree/1.0.10) - 2015-03-19
### Added
- Camera state returned when adding the preview layer.
### Changed
- `README.md` update.
## [1.0.9](https://github.com/imaginary-cloud/CameraManager/tree/1.0.9) - 2015-03-10
### Changed
- CameraManager class made public.
## [1.0.8](https://github.com/imaginary-cloud/CameraManager/tree/1.0.8) - 2015-02-24
### Fixed
- Wrong orientation when camera preview starts in landscape mode.
- Crash when trying to capture a still image.
- Orientation detection failure after stop and resume of a capture session.
- Bug which prevented from recording audio.
## [1.0.7](https://github.com/imaginary-cloud/CameraManager/tree/1.0.7) - 2014-10-30
### Added
- Version compatible with XCode 6.1.
### Changed
- `README.md` update.
- Swift syntax updates to resolve compile errors.
## [1.0.6](https://github.com/imaginary-cloud/CameraManager/tree/1.0.6) - 2014-10-28
### Added
- Check for valid capture session.
### Changed
- Fixed video orientation change.
## [1.0.5](https://github.com/imaginary-cloud/CameraManager/tree/1.0.5) - 2014-10-22
### Changed
- Enhanced Camera lifecyle.
- Orientation observers only added if needed.
## [1.0.4](https://github.com/imaginary-cloud/CameraManager/tree/1.0.4) - 2014-10-16
### Added
- Restart session.
### Changed
- `README.md` update.
## [1.0.3](https://github.com/imaginary-cloud/CameraManager/tree/1.0.3) - 2014-10-15
### Added
- Property `writeFilesToPhoneLibrary` to conditionally write to user library.
### Changed
- Resources only recreated when needed.
- `README.md` update.
## [1.0.2](https://github.com/imaginary-cloud/CameraManager/tree/1.0.2) - 2014-10-15
### Added
- `CameraManager.podspec` file.
## [1.0.1](https://github.com/imaginary-cloud/CameraManager/tree/1.0.1) - 2014-10-15
### Changed
- Optional initializer for `addPreviewLayerToView`.
## [1.0.0](https://github.com/imaginary-cloud/CameraManager/tree/1.0.0) - 2014-10-15
### Added
- Front and back camera selection.
- Support for multiple flash modes.
- Video recording, with or without mic.
- Support for multiple camera output quality.
- Preview layer follows interface orientation changes.

View File

@ -1,13 +1,13 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "CameraManager" s.name = "CameraManager"
s.version = "1.0.4" s.version = "3.0.0"
s.summary = "This is a simple class to provide all the configurations you need to create custom camera view in your app. Just drag, drop and use." s.summary = "This is a simple Swift class to provide all the configurations you need to create custom camera view in your app. Just drag, drop and use."
s.requires_arc = true
s.homepage = "https://github.com/imaginary-cloud/CameraManager" s.homepage = "https://github.com/imaginary-cloud/CameraManager"
s.license = 'MIT' s.license = 'MIT'
s.author = { "nelanelanela" => "nterlecka@imaginarycloud.com" } s.author = { "torrao" => "rtorrao@imaginarycloud.com" }
s.source = { :git => "https://github.com/imaginary-cloud/CameraManager.git", :tag => "1.0.4" } s.source = { :git => "https://github.com/imaginary-cloud/CameraManager.git", :tag => "3.0.0" }
s.social_media_url = 'http://www.imaginarycloud.com/' s.social_media_url = 'http://www.imaginarycloud.com/'
s.platform = :ios, '7.0' s.platform = :ios, '8.0'
s.requires_arc = true
s.source_files = 'camera/CameraManager.swift' s.source_files = 'camera/CameraManager.swift'
end end

View File

@ -0,0 +1,19 @@
//
// CameraManager.h
// CameraManager
//
// Created by Lex Tang on 4/9/15.
// Copyright (c) 2015 imaginaryCloud. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for CameraManager.
FOUNDATION_EXPORT double CameraManagerVersionNumber;
//! Project version string for CameraManager.
FOUNDATION_EXPORT const unsigned char CameraManagerVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <CameraManager/PublicHeader.h>

26
CameraManager/Info.plist Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

12
Package.swift Normal file
View File

@ -0,0 +1,12 @@
// Package.swift
//
// Copyright © 2016 ImaginaryCloud, imaginarycloud.com. This library is licensed under the MIT license.
import PackageDescription
let package = Package(
name: "CameraManager",
targets: [
Target(name: "camera", dependencies: [.Target(name: "CameraManager")])
]
)

View File

@ -1,3 +0,0 @@
platform :ios, '7.1'
pod 'CameraManager', :git => 'https://gist.github.com/2204678.git'

161
README.md
View File

@ -1,86 +1,177 @@
####Camera Manager # Camera Manager
[![CocoaPods](https://img.shields.io/cocoapods/v/CameraManager.svg)](https://github.com/imaginary-cloud/CameraManager) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
V1.0.4 (16-Oct-2014) This is a simple Swift class to provide all the configurations you need to create custom camera view in your app.
It follows orientation change and updates UI accordingly, supports front and rear camera selection, pinch to zoom, different flash modes, inputs and outputs.
####About
This is a simple swift class to provide all the configurations you need to create custom camera view in your app.
Just drag, drop and use. Just drag, drop and use.
####Installation with CocoaPods Now it's compatible with latest Swift syntax if you're using any Swift version prior to 2.0 make sure to use one of the previously tagged releases.
The easiest way to install the CameraManager is with: [CocoaPods](http://cocoapods.org) ## Installation with CocoaPods
## Podfile The easiest way to install the CameraManager is with: [CocoaPods](http://cocoapods.org)
### Podfile
If you want Swift 3.0 syntax use:
```ruby ```ruby
platform :ios, '7.0' use_frameworks!
pod 'CameraManager', '~> 1.0
pod 'CameraManager', '~> 3.0'
``` ```
####How to use If you want Swift 2.0 syntax use:
To use it you just add the preview layer to your desired view
```ruby
use_frameworks!
pod 'CameraManager', '~> 2.2'
```
If you want Swift 1.2 syntax use:
```ruby
use_frameworks!
pod 'CameraManager', '~> 1.0.14'
```
## Installation with Swift Package Manager
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code.
Add `CameraManager` as a dependency in your `Package.swift` file:
```
import PackageDescription
let package = Package(
dependencies: [
.Package(url: "https://github.com/imaginary-cloud/CameraManager", majorVersion: 2, minor: 2)
]
)
```
## Installation with Carthage
[Carthage](https://github.com/Carthage/Carthage) is another dependency management tool written in Swift.
Add the following line to your Cartfile:
If you want Swift 3.0 syntax use:
```
github "imaginary-cloud/CameraManager" >= 3.0
```
If you want Swift 2.0 syntax use:
```
github "imaginary-cloud/CameraManager" >= 2.2
```
If you want Swift 1.2 syntax use:
```
github "imaginary-cloud/CameraManager" >= 1.0
```
And run `carthage update` to build the dynamic framework.
## How to use
To use it you just add the preview layer to your desired view, you'll get back the state of the camera if it's unavailable, ready or the user denied access to it. Have in mind that in order to retain the AVCaptureSession you will need to retain cameraManager instance somewhere, ex. as an instance constant.
```swift ```swift
CameraManager.sharedInstance.addPreeviewLayerToView(self.cameraView) let cameraManager = CameraManager()
cameraManager.addPreviewLayerToView(self.cameraView)
``` ```
You can set input device to front or back camera: You can set input device to front or back camera:
```swift ```swift
CameraManager.sharedInstance.cameraDevice = .Front cameraManager.cameraDevice = .Front
CameraManager.sharedInstance.cameraDevice = .Back cameraManager.cameraDevice = .Back
``` ```
You can set output format to Image, video or video with audio: You can set output format to Image, video or video with audio:
```swift ```swift
CameraManager.sharedInstance.cameraOutputMode = .StillImage cameraManager.cameraOutputMode = .StillImage
CameraManager.sharedInstance.cameraOutputMode = .VideoWithMic cameraManager.cameraOutputMode = .VideoWithMic
CameraManager.sharedInstance.cameraOutputMode = .VideoOnly cameraManager.cameraOutputMode = .VideoOnly
``` ```
You can set the quality: You can set the quality:
```swift ```swift
CameraManager.sharedInstance.cameraOutputQuality = .Low cameraManager.cameraOutputQuality = .Low
CameraManager.sharedInstance.cameraOutputQuality = .Medium cameraManager.cameraOutputQuality = .Medium
CameraManager.sharedInstance.cameraOutputQuality = .High cameraManager.cameraOutputQuality = .High
``` ```
And flash mode: And flash mode (it will also set corresponding torch mode for video shoot):
```swift ```swift
CameraManager.sharedInstance.flashMode = .Off cameraManager.flashMode = .Off
CameraManager.sharedInstance.flashMode = .On cameraManager.flashMode = .On
CameraManager.sharedInstance.flashMode = .Auto cameraManager.flashMode = .Auto
``` ```
To check if the device supports flash call:
```swift
cameraManager.hasFlash
```
To change flash mode to the next available one you can use this handy function which will also return current value for you to update the UI accordingly:
```swift
cameraManager.changeFlashMode()
```
You can specify if you want to save the files to phone library: You can specify if you want to save the files to phone library:
```swift ```swift
CameraManager.sharedInstance.writeFilesToPhoneLibrary = true cameraManager.writeFilesToPhoneLibrary = true
```
You can specify if you want the user to be asked about camera permissions automatically when you first try to use the camera or manually:
```swift
cameraManager.showAccessPermissionPopupAutomatically = false
``` ```
You can even setUp your custom block to handle error messages: You can even setUp your custom block to handle error messages:
It can be customized to be presented on the Window root view controller, for example.
```swift ```swift
CameraManager.sharedInstance.showErrorBlock = { (erTitle: String, erMessage: String) -> Void in cameraManager.showErrorBlock = { (erTitle: String, erMessage: String) -> Void in
UIAlertView(title: erTitle, message: erMessage, delegate: nil, cancelButtonTitle: "OK").show() var alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .Alert)
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (alertAction) -> Void in
}))
let topController = UIApplication.sharedApplication().keyWindow?.rootViewController
if (topController != nil) {
topController?.presentViewController(alertController, animated: true, completion: { () -> Void in
//
})
}
} }
``` ```
To shoot image all you need to do is call: To shoot image all you need to do is call:
```swift ```swift
CameraManager.sharedInstance.capturePictureWithCompletition({ (image) -> Void in cameraManager.capturePictureWithCompletion({ (image, error) -> Void in
self.myImage = image self.myImage = image
}) })
``` ```
To record video you do: To record video you do:
```swift ```swift
CameraManager.sharedInstance.startRecordingVideo() cameraManager.startRecordingVideo()
CameraManager.sharedInstance.stopRecordingVideo({ (videoURL) -> Void in cameraManager.stopVideoRecording({ (videoURL, error) -> Void in
NSFileManager.defaultManager().copyItemAtURL(videoURL, toURL: self.myVideoURL, error: &error) NSFileManager.defaultManager().copyItemAtURL(videoURL, toURL: self.myVideoURL, error: &error)
}) })
``` ```
####Support ## Support
Supports iOS 7 and above Supports iOS 8 and above. Xcode 7.0 is required to build the latest code written in Swift 2.0.
####License ## License
Copyright © 2014 ImaginaryCloud, imaginarycloud.com. This plugin is licensed under the MIT license. Copyright © 2016 ImaginaryCloud, imaginarycloud.com. This library is licensed under the MIT license.

View File

@ -12,9 +12,37 @@
454C1F4C19E82E2500C81915 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 454C1F4A19E82E2500C81915 /* Main.storyboard */; }; 454C1F4C19E82E2500C81915 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 454C1F4A19E82E2500C81915 /* Main.storyboard */; };
454C1F4E19E82E2500C81915 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 454C1F4D19E82E2500C81915 /* Images.xcassets */; }; 454C1F4E19E82E2500C81915 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 454C1F4D19E82E2500C81915 /* Images.xcassets */; };
454C1F5119E82E2500C81915 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 454C1F4F19E82E2500C81915 /* LaunchScreen.xib */; }; 454C1F5119E82E2500C81915 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 454C1F4F19E82E2500C81915 /* LaunchScreen.xib */; };
454C1F6719E8316A00C81915 /* CameraManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 454C1F6619E8316A00C81915 /* CameraManager.swift */; }; 45A23C181A656BDC00FB48F3 /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45A23C171A656BDC00FB48F3 /* ImageViewController.swift */; };
D71DE8861AD677A7001E62F1 /* CameraManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D71DE8851AD677A7001E62F1 /* CameraManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
D71DE8981AD677A8001E62F1 /* CameraManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D71DE8811AD677A7001E62F1 /* CameraManager.framework */; };
D71DE8991AD677A8001E62F1 /* CameraManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D71DE8811AD677A7001E62F1 /* CameraManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D71DE8A11AD677EF001E62F1 /* CameraManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 454C1F6619E8316A00C81915 /* CameraManager.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
D71DE8961AD677A8001E62F1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 454C1F3919E82E2500C81915 /* Project object */;
proxyType = 1;
remoteGlobalIDString = D71DE8801AD677A7001E62F1;
remoteInfo = CameraManager;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
D71DE89D1AD677A8001E62F1 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
D71DE8991AD677A8001E62F1 /* CameraManager.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
454C1F4119E82E2500C81915 /* camera.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = camera.app; sourceTree = BUILT_PRODUCTS_DIR; }; 454C1F4119E82E2500C81915 /* camera.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = camera.app; sourceTree = BUILT_PRODUCTS_DIR; };
454C1F4519E82E2500C81915 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 454C1F4519E82E2500C81915 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@ -23,11 +51,23 @@
454C1F4B19E82E2500C81915 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; 454C1F4B19E82E2500C81915 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
454C1F4D19E82E2500C81915 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; }; 454C1F4D19E82E2500C81915 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
454C1F5019E82E2500C81915 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; }; 454C1F5019E82E2500C81915 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
454C1F6619E8316A00C81915 /* CameraManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CameraManager.swift; sourceTree = "<group>"; }; 454C1F6619E8316A00C81915 /* CameraManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CameraManager.swift; path = ../camera/CameraManager.swift; sourceTree = "<group>"; };
45A23C171A656BDC00FB48F3 /* ImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = "<group>"; };
D71DE8811AD677A7001E62F1 /* CameraManager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CameraManager.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D71DE8841AD677A7001E62F1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D71DE8851AD677A7001E62F1 /* CameraManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CameraManager.h; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
454C1F3E19E82E2500C81915 /* Frameworks */ = { 454C1F3E19E82E2500C81915 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D71DE8981AD677A8001E62F1 /* CameraManager.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
D71DE87D1AD677A7001E62F1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
@ -41,6 +81,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
454C1F4319E82E2500C81915 /* camera */, 454C1F4319E82E2500C81915 /* camera */,
D71DE8821AD677A7001E62F1 /* CameraManager */,
454C1F4219E82E2500C81915 /* Products */, 454C1F4219E82E2500C81915 /* Products */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
@ -49,6 +90,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
454C1F4119E82E2500C81915 /* camera.app */, 454C1F4119E82E2500C81915 /* camera.app */,
D71DE8811AD677A7001E62F1 /* CameraManager.framework */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
@ -57,8 +99,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
454C1F4619E82E2500C81915 /* AppDelegate.swift */, 454C1F4619E82E2500C81915 /* AppDelegate.swift */,
454C1F6619E8316A00C81915 /* CameraManager.swift */, 45A23C191A656BE600FB48F3 /* Example app view controllers */,
454C1F4819E82E2500C81915 /* ViewController.swift */,
454C1F4A19E82E2500C81915 /* Main.storyboard */, 454C1F4A19E82E2500C81915 /* Main.storyboard */,
454C1F4D19E82E2500C81915 /* Images.xcassets */, 454C1F4D19E82E2500C81915 /* Images.xcassets */,
454C1F4F19E82E2500C81915 /* LaunchScreen.xib */, 454C1F4F19E82E2500C81915 /* LaunchScreen.xib */,
@ -75,8 +116,46 @@
name = "Supporting Files"; name = "Supporting Files";
sourceTree = "<group>"; sourceTree = "<group>";
}; };
45A23C191A656BE600FB48F3 /* Example app view controllers */ = {
isa = PBXGroup;
children = (
454C1F4819E82E2500C81915 /* ViewController.swift */,
45A23C171A656BDC00FB48F3 /* ImageViewController.swift */,
);
name = "Example app view controllers";
sourceTree = "<group>";
};
D71DE8821AD677A7001E62F1 /* CameraManager */ = {
isa = PBXGroup;
children = (
D71DE8851AD677A7001E62F1 /* CameraManager.h */,
454C1F6619E8316A00C81915 /* CameraManager.swift */,
D71DE8831AD677A7001E62F1 /* Supporting Files */,
);
path = CameraManager;
sourceTree = "<group>";
};
D71DE8831AD677A7001E62F1 /* Supporting Files */ = {
isa = PBXGroup;
children = (
D71DE8841AD677A7001E62F1 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
D71DE87E1AD677A7001E62F1 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
D71DE8861AD677A7001E62F1 /* CameraManager.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
454C1F4019E82E2500C81915 /* camera */ = { 454C1F4019E82E2500C81915 /* camera */ = {
isa = PBXNativeTarget; isa = PBXNativeTarget;
@ -85,27 +164,54 @@
454C1F3D19E82E2500C81915 /* Sources */, 454C1F3D19E82E2500C81915 /* Sources */,
454C1F3E19E82E2500C81915 /* Frameworks */, 454C1F3E19E82E2500C81915 /* Frameworks */,
454C1F3F19E82E2500C81915 /* Resources */, 454C1F3F19E82E2500C81915 /* Resources */,
D71DE89D1AD677A8001E62F1 /* Embed Frameworks */,
); );
buildRules = ( buildRules = (
); );
dependencies = ( dependencies = (
D71DE8971AD677A8001E62F1 /* PBXTargetDependency */,
); );
name = camera; name = camera;
productName = camera; productName = camera;
productReference = 454C1F4119E82E2500C81915 /* camera.app */; productReference = 454C1F4119E82E2500C81915 /* camera.app */;
productType = "com.apple.product-type.application"; productType = "com.apple.product-type.application";
}; };
D71DE8801AD677A7001E62F1 /* CameraManager */ = {
isa = PBXNativeTarget;
buildConfigurationList = D71DE89A1AD677A8001E62F1 /* Build configuration list for PBXNativeTarget "CameraManager" */;
buildPhases = (
D71DE87C1AD677A7001E62F1 /* Sources */,
D71DE87D1AD677A7001E62F1 /* Frameworks */,
D71DE87E1AD677A7001E62F1 /* Headers */,
D71DE87F1AD677A7001E62F1 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = CameraManager;
productName = CameraManager;
productReference = D71DE8811AD677A7001E62F1 /* CameraManager.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */ /* End PBXNativeTarget section */
/* Begin PBXProject section */ /* Begin PBXProject section */
454C1F3919E82E2500C81915 /* Project object */ = { 454C1F3919E82E2500C81915 /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0600; LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = imaginaryCloud; ORGANIZATIONNAME = imaginaryCloud;
TargetAttributes = { TargetAttributes = {
454C1F4019E82E2500C81915 = { 454C1F4019E82E2500C81915 = {
CreatedOnToolsVersion = 6.0.1; CreatedOnToolsVersion = 6.0.1;
DevelopmentTeam = QM7HJTY23M;
LastSwiftMigration = 0800;
};
D71DE8801AD677A7001E62F1 = {
CreatedOnToolsVersion = 6.3;
LastSwiftMigration = 0800;
}; };
}; };
}; };
@ -123,6 +229,7 @@
projectRoot = ""; projectRoot = "";
targets = ( targets = (
454C1F4019E82E2500C81915 /* camera */, 454C1F4019E82E2500C81915 /* camera */,
D71DE8801AD677A7001E62F1 /* CameraManager */,
); );
}; };
/* End PBXProject section */ /* End PBXProject section */
@ -138,6 +245,13 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
D71DE87F1AD677A7001E62F1 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
@ -146,13 +260,29 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
454C1F4919E82E2500C81915 /* ViewController.swift in Sources */, 454C1F4919E82E2500C81915 /* ViewController.swift in Sources */,
454C1F6719E8316A00C81915 /* CameraManager.swift in Sources */, 45A23C181A656BDC00FB48F3 /* ImageViewController.swift in Sources */,
454C1F4719E82E2500C81915 /* AppDelegate.swift in Sources */, 454C1F4719E82E2500C81915 /* AppDelegate.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
D71DE87C1AD677A7001E62F1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D71DE8A11AD677EF001E62F1 /* CameraManager.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */ /* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
D71DE8971AD677A8001E62F1 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D71DE8801AD677A7001E62F1 /* CameraManager */;
targetProxy = D71DE8961AD677A8001E62F1 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */ /* Begin PBXVariantGroup section */
454C1F4A19E82E2500C81915 /* Main.storyboard */ = { 454C1F4A19E82E2500C81915 /* Main.storyboard */ = {
isa = PBXVariantGroup; isa = PBXVariantGroup;
@ -186,16 +316,20 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer: Luis Diniz (HUX544ZBSL)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1", "DEBUG=1",
@ -211,7 +345,6 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
PROVISIONING_PROFILE = "4d0a483e-6fa4-454e-a019-6ce6d8c6f307";
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
@ -231,8 +364,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@ -240,6 +375,7 @@
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNDECLARED_SELECTOR = YES;
@ -248,8 +384,8 @@
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
PROVISIONING_PROFILE = "4d0a483e-6fa4-454e-a019-6ce6d8c6f307";
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };
@ -259,9 +395,13 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = camera/Info.plist; INFOPLIST_FILE = camera/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = cameraDemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
}; };
name = Debug; name = Debug;
}; };
@ -269,9 +409,66 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = camera/Info.plist; INFOPLIST_FILE = camera/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = cameraDemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
D71DE89B1AD677A8001E62F1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = CameraManager/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.imaginarycloud.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
D71DE89C1AD677A8001E62F1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = CameraManager/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.imaginarycloud.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
}; };
name = Release; name = Release;
}; };
@ -296,6 +493,15 @@
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release; defaultConfigurationName = Release;
}; };
D71DE89A1AD677A8001E62F1 /* Build configuration list for PBXNativeTarget "CameraManager" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D71DE89B1AD677A8001E62F1 /* Debug */,
D71DE89C1AD677A8001E62F1 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */ /* End XCConfigurationList section */
}; };
rootObject = 454C1F3919E82E2500C81915 /* Project object */; rootObject = 454C1F3919E82E2500C81915 /* Project object */;

View File

@ -34,7 +34,7 @@
<key>IDESourceControlWCCIdentifierKey</key> <key>IDESourceControlWCCIdentifierKey</key>
<string>E1D0A3AE6B49B031DF6A25973E5414F28D2A575A</string> <string>E1D0A3AE6B49B031DF6A25973E5414F28D2A575A</string>
<key>IDESourceControlWCCName</key> <key>IDESourceControlWCCName</key>
<string>camera</string> <string>CameraManager</string>
</dict> </dict>
</array> </array>
</dict> </dict>

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D71DE8801AD677A7001E62F1"
BuildableName = "CameraManager.framework"
BlueprintName = "CameraManager"
ReferencedContainer = "container:camera.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D71DE8801AD677A7001E62F1"
BuildableName = "CameraManager.framework"
BlueprintName = "CameraManager"
ReferencedContainer = "container:camera.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D71DE8801AD677A7001E62F1"
BuildableName = "CameraManager.framework"
BlueprintName = "CameraManager"
ReferencedContainer = "container:camera.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0600" LastUpgradeVersion = "0700"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
@ -62,6 +62,8 @@
ReferencedContainer = "container:camera.xcodeproj"> ReferencedContainer = "container:camera.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
@ -71,8 +73,10 @@
buildConfiguration = "Debug" buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<BuildableProductRunnable> <BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "454C1F4019E82E2500C81915" BlueprintIdentifier = "454C1F4019E82E2500C81915"
@ -90,7 +94,8 @@
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
buildConfiguration = "Release" buildConfiguration = "Release"
debugDocumentVersioning = "YES"> debugDocumentVersioning = "YES">
<BuildableProductRunnable> <BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "454C1F4019E82E2500C81915" BlueprintIdentifier = "454C1F4019E82E2500C81915"

View File

@ -12,6 +12,11 @@
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
<dict> <dict>
<key>453228F21AC2AD9A00A7EE76</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>454C1F4019E82E2500C81915</key> <key>454C1F4019E82E2500C81915</key>
<dict> <dict>
<key>primary</key> <key>primary</key>
@ -22,6 +27,11 @@
<key>primary</key> <key>primary</key>
<true/> <true/>
</dict> </dict>
<key>D71DE8801AD677A7001E62F1</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict> </dict>
</dict> </dict>
</plist> </plist>

View File

@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch. // Override point for customization after application launch.
return true return true
} }
func applicationWillResignActive(application: UIApplication) { func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
} }
func applicationDidEnterBackground(application: UIApplication) { func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
} }
func applicationWillEnterForeground(application: UIApplication) { func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
} }
func applicationDidBecomeActive(application: UIApplication) { func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
} }
func applicationWillTerminate(application: UIApplication) { func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
} }

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/> <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies> </dependencies>
<objects> <objects>
@ -11,16 +12,16 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/> <rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2014 imaginaryCloud. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye"> <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2016 imaginaryCloud. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/> <rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="camera" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX"> <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="camera" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/> <rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/> <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
</subviews> </subviews>

View File

@ -1,13 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="bhK-VL-qY4">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies> </dependencies>
<scenes> <scenes>
<!--View Controller--> <!--Camera-->
<scene sceneID="tne-QT-ifu"> <scene sceneID="tne-QT-ifu">
<objects> <objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="camera" customModuleProvider="target" sceneMemberID="viewController"> <viewController title="Camera" id="BYZ-38-t0r" customClass="ViewController" customModule="camera" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides> <layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
@ -21,34 +23,6 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="tintColor" red="0.54901963470000004" green="0.77647066119999997" blue="0.2470588386" alpha="1" colorSpace="deviceRGB"/> <color key="tintColor" red="0.54901963470000004" green="0.77647066119999997" blue="0.2470588386" alpha="1" colorSpace="deviceRGB"/>
</view> </view>
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="yyS-3g-UqL">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sT4-CC-oh5">
<rect key="frame" x="496" y="20" width="88" height="33"/>
<color key="backgroundColor" red="0.98039221759999995" green="0.0078431377190000002" blue="0.52156865600000002" alpha="1" colorSpace="deviceRGB"/>
<state key="normal" title="Front">
<color key="titleColor" red="1" green="0.87630701789999998" blue="0.35755069969999997" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="changeCameraDevice:" destination="BYZ-38-t0r" eventType="touchUpInside" id="KDu-mr-jHd"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="19j-xT-Ttb">
<rect key="frame" x="16" y="20" width="88" height="33"/>
<color key="backgroundColor" red="0.54901963470000004" green="0.77647066119999997" blue="0.2470588386" alpha="1" colorSpace="deviceRGB"/>
<constraints>
<constraint firstAttribute="width" constant="88" id="7mm-eo-7Ng"/>
<constraint firstAttribute="height" constant="33" id="jff-rD-TUp"/>
</constraints>
<state key="normal" title="Flash off">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="changeFlashMode:" destination="BYZ-38-t0r" eventType="touchUpInside" id="e2b-Lg-iqO"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FSo-n8-ZwV"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FSo-n8-ZwV">
<rect key="frame" x="275" y="530" width="50" height="50"/> <rect key="frame" x="275" y="530" width="50" height="50"/>
<color key="backgroundColor" red="0.54901963470000004" green="0.77647066119999997" blue="0.2470588386" alpha="1" colorSpace="deviceRGB"/> <color key="backgroundColor" red="0.54901963470000004" green="0.77647066119999997" blue="0.2470588386" alpha="1" colorSpace="deviceRGB"/>
@ -69,50 +43,178 @@
<action selector="recordButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Ggq-m1-AQB"/> <action selector="recordButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Ggq-m1-AQB"/>
</connections> </connections>
</button> </button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3WP-Xo-FaJ"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rd3-ei-B9P">
<rect key="frame" x="256" y="20" width="88" height="33"/> <rect key="frame" x="4" y="84" width="592" height="512"/>
<color key="backgroundColor" red="1" green="0.87630701789999998" blue="0.35755069969999997" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="1" green="0.0" blue="0.46666669849999998" alpha="0.5" colorSpace="deviceRGB"/>
<state key="normal" title="Video"> <fontDescription key="fontDescription" type="system" pointSize="27"/>
<state key="normal">
<color key="titleColor" red="0.36078432199999999" green="0.36078432199999999" blue="0.36078432199999999" alpha="1" colorSpace="deviceRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state> </state>
<connections> <connections>
<action selector="outputModeButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Bgy-rQ-cfF"/> <action selector="askForCameraPermissions:" destination="BYZ-38-t0r" eventType="touchUpInside" id="gbn-Ql-Lnv"/>
</connections> </connections>
</button> </button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jaF-q9-Eli">
<rect key="frame" x="0.0" y="20" width="600" height="60"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="19j-xT-Ttb">
<rect key="frame" x="0.0" y="0.0" width="150" height="60"/>
<color key="backgroundColor" red="0.67058825489999996" green="0.67058825489999996" blue="0.67058825489999996" alpha="0.70000000000000007" colorSpace="deviceRGB"/>
<state key="normal" title="Flash off">
<color key="titleColor" red="0.0" green="0.50196081400000003" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="changeFlashMode:" destination="BYZ-38-t0r" eventType="touchUpInside" id="e2b-Lg-iqO"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3WP-Xo-FaJ">
<rect key="frame" x="150" y="0.0" width="150" height="60"/>
<color key="backgroundColor" red="1" green="0.0" blue="0.46666669849999998" alpha="0.70000000000000007" colorSpace="deviceRGB"/>
<state key="normal" title="Video">
<color key="titleColor" red="0.0" green="0.50196081400000003" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="outputModeButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Bgy-rQ-cfF"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sT4-CC-oh5">
<rect key="frame" x="300" y="0.0" width="150" height="60"/>
<color key="backgroundColor" red="0.67058825489999996" green="0.67058825489999996" blue="0.67058825489999996" alpha="0.70000000000000007" colorSpace="deviceRGB"/>
<state key="normal" title="Back">
<color key="titleColor" red="0.0" green="0.50196081400000003" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="changeCameraDevice:" destination="BYZ-38-t0r" eventType="touchUpInside" id="KDu-mr-jHd"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JCk-74-YkH">
<rect key="frame" x="450" y="0.0" width="150" height="60"/>
<color key="backgroundColor" red="1" green="0.0" blue="0.46666669849999998" alpha="0.70000000000000007" colorSpace="deviceRGB"/>
<state key="normal" title="High">
<color key="titleColor" red="0.0" green="0.50196081400000003" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="changeCameraQuality:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Bt4-RC-Mrl"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="19j-xT-Ttb" firstAttribute="width" secondItem="3WP-Xo-FaJ" secondAttribute="width" id="0JS-OH-a4X"/>
<constraint firstItem="3WP-Xo-FaJ" firstAttribute="leading" secondItem="19j-xT-Ttb" secondAttribute="trailing" id="7Y0-vo-2GG"/>
<constraint firstItem="sT4-CC-oh5" firstAttribute="width" secondItem="3WP-Xo-FaJ" secondAttribute="width" id="Anx-2O-O5g"/>
<constraint firstItem="19j-xT-Ttb" firstAttribute="top" secondItem="jaF-q9-Eli" secondAttribute="top" id="Faq-Kx-fdW"/>
<constraint firstAttribute="bottom" secondItem="3WP-Xo-FaJ" secondAttribute="bottom" id="Jk9-HY-RKV"/>
<constraint firstItem="JCk-74-YkH" firstAttribute="top" secondItem="jaF-q9-Eli" secondAttribute="top" id="Jxn-jp-3u1"/>
<constraint firstItem="19j-xT-Ttb" firstAttribute="width" secondItem="jaF-q9-Eli" secondAttribute="width" multiplier="1:4" id="R5r-hS-YXf"/>
<constraint firstAttribute="trailing" secondItem="JCk-74-YkH" secondAttribute="trailing" id="U8V-vs-AHd"/>
<constraint firstAttribute="bottom" secondItem="sT4-CC-oh5" secondAttribute="bottom" id="X9n-5F-9S6"/>
<constraint firstAttribute="bottom" secondItem="19j-xT-Ttb" secondAttribute="bottom" id="XIm-83-qDg"/>
<constraint firstItem="19j-xT-Ttb" firstAttribute="leading" secondItem="jaF-q9-Eli" secondAttribute="leading" id="YKC-TE-A4C"/>
<constraint firstItem="sT4-CC-oh5" firstAttribute="top" secondItem="jaF-q9-Eli" secondAttribute="top" id="dt8-f3-OG0"/>
<constraint firstItem="sT4-CC-oh5" firstAttribute="leading" secondItem="3WP-Xo-FaJ" secondAttribute="trailing" id="f9i-42-p49"/>
<constraint firstAttribute="bottom" secondItem="JCk-74-YkH" secondAttribute="bottom" id="jye-Mv-9Rq"/>
<constraint firstItem="JCk-74-YkH" firstAttribute="leading" secondItem="sT4-CC-oh5" secondAttribute="trailing" id="mhQ-5m-h5c"/>
<constraint firstAttribute="height" constant="60" id="mlL-sQ-rnK"/>
<constraint firstItem="3WP-Xo-FaJ" firstAttribute="top" secondItem="jaF-q9-Eli" secondAttribute="top" id="oeK-QK-BDl"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Tap here to enable camera access and take great pictures" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2bK-wq-6Rf">
<rect key="frame" x="4" y="84" width="592" height="512"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<color key="textColor" red="0.36078432199999999" green="0.36078432199999999" blue="0.36078432199999999" alpha="1" colorSpace="deviceRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/> <gestureRecognizers/>
<constraints> <constraints>
<constraint firstItem="yyS-3g-UqL" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="2RH-Jf-TPm"/> <constraint firstItem="2bK-wq-6Rf" firstAttribute="top" secondItem="rd3-ei-B9P" secondAttribute="top" id="0KQ-L2-vRf"/>
<constraint firstItem="19j-xT-Ttb" firstAttribute="height" secondItem="3WP-Xo-FaJ" secondAttribute="height" id="3Fa-ID-yp6"/> <constraint firstAttribute="trailing" secondItem="jaF-q9-Eli" secondAttribute="trailing" id="2fZ-BE-g5j"/>
<constraint firstItem="19j-xT-Ttb" firstAttribute="width" secondItem="3WP-Xo-FaJ" secondAttribute="width" id="8aO-Xm-KH2"/> <constraint firstItem="2bK-wq-6Rf" firstAttribute="top" secondItem="jaF-q9-Eli" secondAttribute="bottom" constant="4" id="8fE-gJ-Hi7"/>
<constraint firstItem="EI2-CK-oqA" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="E1I-Yh-igT"/> <constraint firstItem="EI2-CK-oqA" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="E1I-Yh-igT"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="yyS-3g-UqL" secondAttribute="bottom" id="INX-TM-tak"/> <constraint firstItem="rd3-ei-B9P" firstAttribute="bottom" secondItem="EI2-CK-oqA" secondAttribute="bottom" constant="-4" id="GKS-w4-B8J"/>
<constraint firstAttribute="trailing" secondItem="yyS-3g-UqL" secondAttribute="trailing" id="JEu-x6-qah"/> <constraint firstItem="2bK-wq-6Rf" firstAttribute="bottom" secondItem="rd3-ei-B9P" secondAttribute="bottom" id="J9p-Wn-xC4"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="EI2-CK-oqA" secondAttribute="bottom" id="JW8-WC-69E"/> <constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="EI2-CK-oqA" secondAttribute="bottom" id="JW8-WC-69E"/>
<constraint firstItem="19j-xT-Ttb" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="K6V-FG-8Ms"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="FSo-n8-ZwV" secondAttribute="bottom" constant="20" id="KgN-t9-iTh"/> <constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="FSo-n8-ZwV" secondAttribute="bottom" constant="20" id="KgN-t9-iTh"/>
<constraint firstAttribute="trailing" secondItem="sT4-CC-oh5" secondAttribute="trailing" constant="16" id="Q92-5b-7Z7"/> <constraint firstItem="jaF-q9-Eli" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" constant="20" id="Tv6-Ak-cSA"/>
<constraint firstItem="yyS-3g-UqL" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="SyJ-SX-ooI"/>
<constraint firstItem="EI2-CK-oqA" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="Y9T-eB-SQS"/> <constraint firstItem="EI2-CK-oqA" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="Y9T-eB-SQS"/>
<constraint firstItem="3WP-Xo-FaJ" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="aur-kS-Ri3"/> <constraint firstItem="2bK-wq-6Rf" firstAttribute="trailing" secondItem="rd3-ei-B9P" secondAttribute="trailing" id="add-TX-ds6"/>
<constraint firstAttribute="centerX" secondItem="3WP-Xo-FaJ" secondAttribute="centerX" id="c8T-oR-vKi"/> <constraint firstAttribute="trailing" secondItem="rd3-ei-B9P" secondAttribute="trailing" constant="4" id="dJE-jw-ZNY"/>
<constraint firstAttribute="centerX" secondItem="FSo-n8-ZwV" secondAttribute="centerX" id="dQf-Ne-km4"/> <constraint firstAttribute="centerX" secondItem="FSo-n8-ZwV" secondAttribute="centerX" id="dQf-Ne-km4"/>
<constraint firstItem="19j-xT-Ttb" firstAttribute="width" secondItem="sT4-CC-oh5" secondAttribute="width" id="dei-D3-qWh"/> <constraint firstItem="jaF-q9-Eli" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="eAr-PL-deK"/>
<constraint firstItem="sT4-CC-oh5" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="i1Z-3m-ytG"/>
<constraint firstAttribute="trailing" secondItem="EI2-CK-oqA" secondAttribute="trailing" id="m1R-4g-dGU"/> <constraint firstAttribute="trailing" secondItem="EI2-CK-oqA" secondAttribute="trailing" id="m1R-4g-dGU"/>
<constraint firstItem="19j-xT-Ttb" firstAttribute="height" secondItem="sT4-CC-oh5" secondAttribute="height" id="mpG-Ir-vxB"/> <constraint firstItem="rd3-ei-B9P" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="4" id="n5z-dZ-b1l"/>
<constraint firstItem="19j-xT-Ttb" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="16" id="uuM-vU-IPX"/> <constraint firstItem="2bK-wq-6Rf" firstAttribute="leading" secondItem="rd3-ei-B9P" secondAttribute="leading" id="vNM-yq-5jd"/>
</constraints> </constraints>
</view> </view>
<navigationItem key="navigationItem" id="EiR-i7-mkA"/>
<nil key="simulatedTopBarMetrics"/>
<connections> <connections>
<outlet property="askForPermissionsButton" destination="rd3-ei-B9P" id="Itb-t1-HpD"/>
<outlet property="askForPermissionsLabel" destination="2bK-wq-6Rf" id="GdV-Gq-uSS"/>
<outlet property="cameraButton" destination="FSo-n8-ZwV" id="ITk-de-2LY"/> <outlet property="cameraButton" destination="FSo-n8-ZwV" id="ITk-de-2LY"/>
<outlet property="cameraView" destination="EI2-CK-oqA" id="bUS-Rk-omr"/> <outlet property="cameraView" destination="EI2-CK-oqA" id="bUS-Rk-omr"/>
<outlet property="imageView" destination="yyS-3g-UqL" id="CZo-cW-NXH"/> <outlet property="flashModeButton" destination="19j-xT-Ttb" id="hjy-cj-bcm"/>
</connections> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="709" y="102"/>
</scene>
<!--Image-->
<scene sceneID="EDW-uZ-RNP">
<objects>
<viewController storyboardIdentifier="ImageVC" title="Image" id="xF2-bQ-3ri" customClass="ImageViewController" customModule="camera" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="LQz-Um-h4k"/>
<viewControllerLayoutGuide type="bottom" id="qVT-yr-0bo"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Qhk-xW-6b1">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="v1g-94-paQ">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="v1g-94-paQ" firstAttribute="leading" secondItem="Qhk-xW-6b1" secondAttribute="leading" id="AJ6-Mx-ha2"/>
<constraint firstItem="qVT-yr-0bo" firstAttribute="top" secondItem="v1g-94-paQ" secondAttribute="bottom" id="QTs-sj-GPP"/>
<constraint firstAttribute="trailing" secondItem="v1g-94-paQ" secondAttribute="trailing" id="SFa-Zd-kVH"/>
<constraint firstItem="v1g-94-paQ" firstAttribute="top" secondItem="Qhk-xW-6b1" secondAttribute="top" id="jLa-Hd-QGr"/>
</constraints>
</view>
<connections>
<outlet property="imageView" destination="v1g-94-paQ" id="x8J-Uk-fu3"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="caE-Sy-maH" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1460" y="97"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="s7F-c8-PK8">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="bhK-VL-qY4" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="Gas-AK-MC9">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="gVy-l9-gbi"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="atD-jO-HGu" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-103" y="102"/> <point key="canvasLocation" x="-103" y="102"/>
</scene> </scene>
</scenes> </scenes>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,653 @@
//
// CameraManager.swift
// camera
//
// Created by Natalia Terlecka on 10/10/14.
// Copyright (c) 2014 imaginaryCloud. All rights reserved.
//
import UIKit
import AVFoundation
import AssetsLibrary
private let _singletonSharedInstance = CameraManager()
enum CameraDevice {
case Front, Back
}
enum CameraFlashMode: Int {
case Off, On, Auto
}
enum CameraOutputMode {
case StillImage, VideoWithMic, VideoOnly
}
enum CameraOutputQuality {
case Low, Medium, High
}
/// Class for handling iDevices custom camera usage
class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate {
/// Capture session to customize camera settings.
var captureSession: AVCaptureSession?
/// Property to determine if the manager should show the error for the user. If you want to show the errors yourself set this to false. If you want to add custom error UI set showErrorBlock property. Default value is true.
var showErrorsToUsers = true
/// A block creating UI to present error message to the user.
var showErrorBlock:(erTitle: String, erMessage: String) -> Void = { (erTitle: String, erMessage: String) -> Void in
UIAlertView(title: erTitle, message: erMessage, delegate: nil, cancelButtonTitle: "OK").show()
}
/// Property to determine if manager should write the resources to the phone library. Default value is true.
var writeFilesToPhoneLibrary = true
/// The Bool property to determin if current device has front camera.
var hasFrontCamera: Bool = {
let devices = AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo)
for device in devices {
let captureDevice = device as AVCaptureDevice
if (captureDevice.position == .Front) {
return true
}
}
return false
}()
/// Property to change camera device between front and back.
var cameraDevice: CameraDevice {
get {
return _cameraDevice
}
set(newCameraDevice) {
if let validCaptureSession = self.captureSession {
validCaptureSession.beginConfiguration()
let inputs = validCaptureSession.inputs as [AVCaptureInput]
switch newCameraDevice {
case .Front:
if self.hasFrontCamera {
if let validBackDevice = self.rearCamera? {
if contains(inputs, validBackDevice) {
validCaptureSession.removeInput(validBackDevice)
}
}
if let validFrontDevice = self.frontCamera? {
if !contains(inputs, validFrontDevice) {
validCaptureSession.addInput(validFrontDevice)
}
}
}
case .Back:
if let validFrontDevice = self.frontCamera? {
if contains(inputs, validFrontDevice) {
validCaptureSession.removeInput(validFrontDevice)
}
}
if let validBackDevice = self.rearCamera? {
if !contains(inputs, validBackDevice) {
validCaptureSession.addInput(validBackDevice)
}
}
}
validCaptureSession.commitConfiguration()
}
_cameraDevice = newCameraDevice
}
}
/// Property to change camera flash mode.
var flashMode: CameraFlashMode {
get {
return _flashMode
}
set(newflashMode) {
if newflashMode != _flashMode {
self.captureSession?.beginConfiguration()
let devices = AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo)
for device in devices {
let captureDevice = device as AVCaptureDevice
if (captureDevice.position == AVCaptureDevicePosition.Back) {
let avFlashMode = AVCaptureFlashMode(rawValue: newflashMode.rawValue)
if (captureDevice.isFlashModeSupported(avFlashMode!)) {
captureDevice.lockForConfiguration(nil)
captureDevice.flashMode = avFlashMode!
captureDevice.unlockForConfiguration()
}
}
}
self.captureSession?.commitConfiguration()
_flashMode = newflashMode
}
}
}
/// Property to change camera output quality.
var cameraOutputQuality: CameraOutputQuality {
get {
return _cameraOutputQuality
}
set(newCameraOutputQuality) {
if newCameraOutputQuality != _cameraOutputQuality {
if let validCaptureSession = self.captureSession? {
validCaptureSession.beginConfiguration()
switch (newCameraOutputQuality) {
case CameraOutputQuality.Low:
validCaptureSession.sessionPreset = AVCaptureSessionPresetLow
case CameraOutputQuality.Medium:
validCaptureSession.sessionPreset = AVCaptureSessionPresetMedium
case CameraOutputQuality.High:
validCaptureSession.sessionPreset = AVCaptureSessionPresetHigh
}
validCaptureSession.commitConfiguration()
_cameraOutputQuality = newCameraOutputQuality
} else {
self._show("Camera error", message: "No valid capture session found, I can't take any pictures or videos.")
}
}
}
}
/// Property to change camera output.
var cameraOutputMode: CameraOutputMode {
get {
return _cameraOutputMode
}
set(newCameraOutputMode) {
if newCameraOutputMode != _cameraOutputMode {
self._setupOutputMode(newCameraOutputMode)
}
}
}
private weak var embedingView: UIView?
private var videoCompletition: ((videoURL: NSURL) -> Void)?
private var sessionQueue: dispatch_queue_t = dispatch_queue_create("CameraSessionQueue", DISPATCH_QUEUE_SERIAL)
private var frontCamera: AVCaptureInput?
private var rearCamera: AVCaptureInput?
private var mic: AVCaptureDeviceInput?
private var stillImageOutput: AVCaptureStillImageOutput?
private var movieOutput: AVCaptureMovieFileOutput?
private var previewLayer: AVCaptureVideoPreviewLayer?
private var library: ALAssetsLibrary?
private var cameraIsSetup = false
private var cameraIsObservingDeviceOrientation = false
private var _cameraDevice = CameraDevice.Back
private var _flashMode = CameraFlashMode.Off
private var _cameraOutputMode = CameraOutputMode.StillImage
private var _cameraOutputQuality = CameraOutputQuality.High
private var tempFilePath: NSURL = {
let tempPath = NSTemporaryDirectory().stringByAppendingPathComponent("tempMovie").stringByAppendingPathExtension("mp4")
if NSFileManager.defaultManager().fileExistsAtPath(tempPath!) {
NSFileManager.defaultManager().removeItemAtPath(tempPath!, error: nil)
}
return NSURL(fileURLWithPath: tempPath!)!
}()
/// CameraManager singleton instance to use the camera.
class var sharedInstance: CameraManager {
return _singletonSharedInstance
}
deinit {
self.stopAndRemoveCaptureSession()
self._stopFollowingDeviceOrientation()
}
/**
Inits a capture session and adds a preview layer to the given view. Preview layer bounds will automaticaly be set to match given view. Default session is initialized with still image output.
:param: view The view you want to add the preview layer to
:param: cameraOutputMode The mode you want capturesession to run image / video / video and microphone
*/
func addPreviewLayerToView(view: UIView)
{
self.addPreviewLayerToView(view, newCameraOutputMode: _cameraOutputMode)
}
func addPreviewLayerToView(view: UIView, newCameraOutputMode: CameraOutputMode)
{
if let validEmbedingView = self.embedingView? {
if let validPreviewLayer = self.previewLayer? {
validPreviewLayer.removeFromSuperlayer()
}
}
if self.cameraIsSetup {
self._addPreeviewLayerToView(view)
self.cameraOutputMode = newCameraOutputMode
} else {
self._setupCamera({ Void -> Void in
self._addPreeviewLayerToView(view)
self.cameraOutputMode = newCameraOutputMode
})
}
}
/**
Stops running capture session but all setup devices, inputs and outputs stay for further reuse.
*/
func stopCaptureSession()
{
self.captureSession?.stopRunning()
self._stopFollowingDeviceOrientation()
}
/**
Resumes capture session.
*/
func resumeCaptureSession()
{
if let validCaptureSession = self.captureSession? {
if !validCaptureSession.running && self.cameraIsSetup {
validCaptureSession.startRunning()
self._startFollowingDeviceOrientation()
}
} else {
if self.cameraIsSetup {
self.stopAndRemoveCaptureSession()
}
self._setupCamera({Void -> Void in
if let validEmbedingView = self.embedingView? {
self._addPreeviewLayerToView(validEmbedingView)
}
self._startFollowingDeviceOrientation()
})
}
}
/**
Stops running capture session and removes all setup devices, inputs and outputs.
*/
func stopAndRemoveCaptureSession()
{
self.stopCaptureSession()
self.cameraDevice = .Back
self.cameraIsSetup = false
self.previewLayer = nil
self.captureSession = nil
self.frontCamera = nil
self.rearCamera = nil
self.mic = nil
self.stillImageOutput = nil
self.movieOutput = nil
}
/**
Captures still image from currently running capture session.
:param: imageCompletition Completition block containing the captured UIImage
*/
func capturePictureWithCompletition(imageCompletition: UIImage -> Void)
{
if self.cameraIsSetup {
if self.cameraOutputMode == .StillImage {
dispatch_async(self.sessionQueue, {
self._getStillImageOutput().captureStillImageAsynchronouslyFromConnection(self._getStillImageOutput().connectionWithMediaType(AVMediaTypeVideo), completionHandler: { [weak self] (sample: CMSampleBuffer!, error: NSError!) -> Void in
if (error? != nil) {
dispatch_async(dispatch_get_main_queue(), {
if let weakSelf = self {
weakSelf._show("error", message: error.localizedDescription)
}
})
} else {
let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sample)
if let weakSelf = self {
if weakSelf.writeFilesToPhoneLibrary {
if let validLibrary = weakSelf.library? {
validLibrary.writeImageDataToSavedPhotosAlbum(imageData, metadata:nil, completionBlock: {
(picUrl, error) -> Void in
if (error? != nil) {
dispatch_async(dispatch_get_main_queue(), {
weakSelf._show("error", message: error.localizedDescription)
})
}
})
}
}
}
imageCompletition(UIImage(data: imageData)!)
}
})
})
} else {
self._show("Capture session output mode video", message: "I can't take any picture")
}
} else {
self._show("No capture session setup", message: "I can't take any picture")
}
}
/**
Starts recording a video with or without voice as in the session preset.
*/
func startRecordingVideo()
{
if self.cameraOutputMode != .StillImage {
self._getMovieOutput().startRecordingToOutputFileURL(self.tempFilePath, recordingDelegate: self)
} else {
self._show("Capture session output still image", message: "I can only take pictures")
}
}
/**
Stop recording a video. Save it to the cameraRoll and give back the url.
*/
func stopRecordingVideo(completition:(videoURL: NSURL) -> Void)
{
if let runningMovieOutput = self.movieOutput {
if runningMovieOutput.recording {
self.videoCompletition = completition
runningMovieOutput.stopRecording()
}
}
}
// PRAGMA MARK - AVCaptureFileOutputRecordingDelegate
func captureOutput(captureOutput: AVCaptureFileOutput!, didStartRecordingToOutputFileAtURL fileURL: NSURL!, fromConnections connections: [AnyObject]!)
{
}
func captureOutput(captureOutput: AVCaptureFileOutput!, didFinishRecordingToOutputFileAtURL outputFileURL: NSURL!, fromConnections connections: [AnyObject]!, error: NSError!)
{
if (error != nil) {
self._show("Unable to save video to the iPhone", message: error.localizedDescription)
} else {
if let validLibrary = self.library? {
if self.writeFilesToPhoneLibrary {
validLibrary.writeVideoAtPathToSavedPhotosAlbum(outputFileURL, completionBlock: { (assetURL: NSURL?, error: NSError?) -> Void in
if (error != nil) {
self._show("Unable to save video to the iPhone.", message: error!.localizedDescription)
} else {
if let validAssetURL = assetURL {
self._executeVideoCompletitionWithURL(validAssetURL)
}
}
})
} else {
self._executeVideoCompletitionWithURL(outputFileURL)
}
}
}
}
// PRAGMA MARK - CameraManager()
private func _executeVideoCompletitionWithURL(url: NSURL)
{
if let validCompletition = self.videoCompletition {
validCompletition(videoURL: url)
self.videoCompletition = nil
}
}
private func _getMovieOutput() -> AVCaptureMovieFileOutput
{
var shouldReinitializeMovieOutput = self.movieOutput == nil
if !shouldReinitializeMovieOutput {
if let connection = self.movieOutput!.connectionWithMediaType(AVMediaTypeVideo) {
shouldReinitializeMovieOutput = shouldReinitializeMovieOutput || !connection.active
}
}
if shouldReinitializeMovieOutput {
self.movieOutput = AVCaptureMovieFileOutput()
self.captureSession?.beginConfiguration()
self.captureSession?.addOutput(self.movieOutput)
self.captureSession?.commitConfiguration()
}
return self.movieOutput!
}
private func _getStillImageOutput() -> AVCaptureStillImageOutput
{
var shouldReinitializeStillImageOutput = self.stillImageOutput == nil
if !shouldReinitializeStillImageOutput {
if let connection = self.stillImageOutput!.connectionWithMediaType(AVMediaTypeVideo) {
shouldReinitializeStillImageOutput = shouldReinitializeStillImageOutput || !connection.active
}
}
if shouldReinitializeStillImageOutput {
self.stillImageOutput = AVCaptureStillImageOutput()
self.captureSession?.beginConfiguration()
self.captureSession?.addOutput(self.stillImageOutput)
self.captureSession?.commitConfiguration()
}
return self.stillImageOutput!
}
@objc private func _orientationChanged()
{
var currentConnection: AVCaptureConnection?;
switch self.cameraOutputMode {
case .StillImage:
currentConnection = self.stillImageOutput?.connectionWithMediaType(AVMediaTypeVideo)
case .VideoOnly, .VideoWithMic:
currentConnection = self._getMovieOutput().connectionWithMediaType(AVMediaTypeVideo)
}
if let validPreviewLayer = self.previewLayer? {
if let validPreviewLayerConnection = validPreviewLayer.connection? {
if validPreviewLayerConnection.supportsVideoOrientation {
validPreviewLayerConnection.videoOrientation = self._currentVideoOrientation()
}
}
if let validOutputLayerConnection = currentConnection? {
if validOutputLayerConnection.supportsVideoOrientation {
validOutputLayerConnection.videoOrientation = self._currentVideoOrientation()
}
}
dispatch_async(dispatch_get_main_queue(), { () -> Void in
if let validEmbedingView = self.embedingView? {
validPreviewLayer.frame = validEmbedingView.bounds
}
})
}
}
private func _currentVideoOrientation() -> AVCaptureVideoOrientation
{
switch UIDevice.currentDevice().orientation {
case .LandscapeLeft:
return .LandscapeRight
case .LandscapeRight:
return .LandscapeLeft
default:
return .Portrait
}
}
private func _setupCamera(completition: Void -> Void)
{
if self._checkIfCameraIsAvailable() {
self.captureSession = AVCaptureSession()
dispatch_async(sessionQueue, {
if let validCaptureSession = self.captureSession? {
validCaptureSession.beginConfiguration()
validCaptureSession.sessionPreset = AVCaptureSessionPresetHigh
self._addVideoInput()
self._setupOutputs()
self._setupOutputMode(self._cameraOutputMode)
self.cameraOutputQuality = self._cameraOutputQuality
self._setupPreviewLayer()
validCaptureSession.commitConfiguration()
validCaptureSession.startRunning()
self._startFollowingDeviceOrientation()
self.cameraIsSetup = true
completition()
}
})
} else {
self._show("Camera unavailable", message: "The device does not have a camera")
}
}
private func _startFollowingDeviceOrientation()
{
if !self.cameraIsObservingDeviceOrientation {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "_orientationChanged", name: UIDeviceOrientationDidChangeNotification, object: nil)
self.cameraIsObservingDeviceOrientation = true
}
}
private func _stopFollowingDeviceOrientation()
{
if self.cameraIsObservingDeviceOrientation {
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIDeviceOrientationDidChangeNotification, object: nil)
self.cameraIsObservingDeviceOrientation = false
}
}
private func _addPreeviewLayerToView(view: UIView)
{
self.embedingView = view
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.previewLayer?.frame = view.layer.bounds
view.clipsToBounds = true
view.layer.addSublayer(self.previewLayer)
})
}
private func _checkIfCameraIsAvailable() -> Bool
{
let deviceHasCamera = UIImagePickerController.isCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Rear) || UIImagePickerController.isCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Front)
return deviceHasCamera
}
private func _addVideoInput()
{
var error: NSError?
if (self.frontCamera? == nil) || (self.rearCamera? == nil) {
var videoFrontDevice: AVCaptureDevice?
var videoBackDevice: AVCaptureDevice?
for device: AnyObject in AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo) {
if device.position == AVCaptureDevicePosition.Back {
videoBackDevice = device as? AVCaptureDevice
} else if device.position == AVCaptureDevicePosition.Front {
videoFrontDevice = device as? AVCaptureDevice
}
}
if (self.frontCamera? == nil) {
if let validVideoFrontDevice = videoFrontDevice? {
self.frontCamera = AVCaptureDeviceInput.deviceInputWithDevice(validVideoFrontDevice, error: &error) as AVCaptureDeviceInput
}
}
if (self.rearCamera? == nil) {
if let validVideoBackDevice = videoBackDevice? {
self.rearCamera = AVCaptureDeviceInput.deviceInputWithDevice(validVideoBackDevice, error: &error) as AVCaptureDeviceInput
}
}
if let validError = error? {
self._show("Device setup error occured", message: validError.localizedDescription)
}
}
self.cameraDevice = _cameraDevice
}
private func _setupMic()
{
if (self.mic == nil) {
var error: NSError?
let micDevice:AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio);
self.mic = AVCaptureDeviceInput.deviceInputWithDevice(micDevice, error: &error) as? AVCaptureDeviceInput;
if let errorHappened = error? {
self.mic = nil
self._show("Mic error", message: errorHappened.description)
}
}
}
private func _setupOutputMode(newCameraOutputMode: CameraOutputMode)
{
self.captureSession?.beginConfiguration()
if (_cameraOutputMode != newCameraOutputMode) {
// remove current setting
switch _cameraOutputMode {
case .StillImage:
if let validStillImageOutput = self.stillImageOutput? {
self.captureSession?.removeOutput(validStillImageOutput)
}
case .VideoOnly, .VideoWithMic:
if let validMovieOutput = self.movieOutput? {
self.captureSession?.removeOutput(validMovieOutput)
}
if _cameraOutputMode == .VideoWithMic {
if let validMic = self.mic? {
self.captureSession?.removeInput(validMic)
}
}
}
}
// configure new devices
switch newCameraOutputMode {
case .StillImage:
if (self.stillImageOutput == nil) {
self._setupOutputs()
}
if let validStillImageOutput = self.stillImageOutput? {
self.captureSession?.addOutput(validStillImageOutput)
}
case .VideoOnly, .VideoWithMic:
self.captureSession?.addOutput(self._getMovieOutput())
if newCameraOutputMode == .VideoWithMic {
if (self.mic == nil) {
self._setupMic()
}
if let validMic = self.mic? {
self.captureSession?.addInput(validMic)
}
}
}
self.captureSession?.commitConfiguration()
_cameraOutputMode = newCameraOutputMode;
self._orientationChanged()
}
private func _setupOutputs()
{
if (self.stillImageOutput == nil) {
self.stillImageOutput = AVCaptureStillImageOutput()
}
if (self.movieOutput == nil) {
self.movieOutput = AVCaptureMovieFileOutput()
}
if self.library == nil {
self.library = ALAssetsLibrary()
}
}
private func _setupPreviewLayer()
{
if let validCaptureSession = self.captureSession? {
self.previewLayer = AVCaptureVideoPreviewLayer(session: validCaptureSession)
self.previewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
}
}
private func _show(title: String, message: String)
{
if self.showErrorsToUsers {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.showErrorBlock(erTitle: title, erMessage: message)
})
}
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BaseBundlePath</key>
<string>/Applications/TextMate.app/Contents/Library/QuickLook/TextMateQL.qlgenerator</string>
</dict>
</plist>

View File

@ -0,0 +1,30 @@
//
// ImageViewController.swift
// camera
//
// Created by Natalia Terlecka on 13/01/15.
// Copyright (c) 2015 imaginaryCloud. All rights reserved.
//
import UIKit
class ImageViewController: UIViewController {
var image: UIImage?
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.isHidden = false
if let validImage = self.image {
self.imageView.image = validImage
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

View File

@ -2,12 +2,18 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>CameraManager will access your photo library to save pictures/video.</string>
<key>NSMicrophoneUsageDescription</key>
<string>CameraManager will use your microphone to record audio for videos.</string>
<key>NSCameraUsageDescription</key>
<string>CameraManager will use your camera to take pictures/video.</string>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.dotzar.camera</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
@ -15,7 +21,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0</string> <string>1.0.14</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>

View File

@ -7,81 +7,171 @@
// //
import UIKit import UIKit
import CameraManager
class ViewController: UIViewController { class ViewController: UIViewController {
let cameraManager = CameraManager.sharedInstance // MARK: - Constants
let cameraManager = CameraManager()
// MARK: - @IBOutlets
@IBOutlet weak var cameraView: UIView! @IBOutlet weak var cameraView: UIView!
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var cameraButton: UIButton! @IBOutlet weak var cameraButton: UIButton!
@IBOutlet weak var flashModeButton: UIButton!
override func viewDidLoad() @IBOutlet weak var askForPermissionsButton: UIButton!
@IBOutlet weak var askForPermissionsLabel: UILabel!
// MARK: - UIViewController
override func viewDidLoad() {
super.viewDidLoad()
cameraManager.showAccessPermissionPopupAutomatically = false
askForPermissionsButton.isHidden = true
askForPermissionsLabel.isHidden = true
let currentCameraState = cameraManager.currentCameraStatus()
if currentCameraState == .notDetermined {
askForPermissionsButton.isHidden = false
askForPermissionsLabel.isHidden = false
} else if (currentCameraState == .ready) {
addCameraToView()
}
if !cameraManager.hasFlash {
flashModeButton.isEnabled = false
flashModeButton.setTitle("No flash", for: UIControlState())
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.isHidden = true
cameraManager.resumeCaptureSession()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
cameraManager.stopCaptureSession()
}
// MARK: - ViewController
fileprivate func addCameraToView()
{ {
super.viewDidLoad() cameraManager.addPreviewLayerToView(cameraView, newCameraOutputMode: CameraOutputMode.videoWithMic)
self.cameraManager.addPreviewLayerToView(self.cameraView, newCameraOutputMode: CameraOutputMode.VideoWithMic) cameraManager.showErrorBlock = { [weak self] (erTitle: String, erMessage: String) -> Void in
self.cameraManager.cameraDevice = .Front
self.imageView.hidden = true let alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .alert)
CameraManager.sharedInstance.showErrorBlock = { (erTitle: String, erMessage: String) -> Void in alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (alertAction) -> Void in }))
UIAlertView(title: erTitle, message: erMessage, delegate: nil, cancelButtonTitle: "OK").show()
self?.present(alertController, animated: true, completion: nil)
}
}
// MARK: - @IBActions
@IBAction func changeFlashMode(_ sender: UIButton)
{
switch (cameraManager.changeFlashMode()) {
case .off:
sender.setTitle("Flash Off", for: UIControlState())
case .on:
sender.setTitle("Flash On", for: UIControlState())
case .auto:
sender.setTitle("Flash Auto", for: UIControlState())
} }
} }
@IBAction func changeFlashMode(sender: UIButton) @IBAction func recordButtonTapped(_ sender: UIButton) {
{
self.cameraManager.flashMode = CameraFlashMode.fromRaw((self.cameraManager.flashMode.toRaw()+1)%3)! switch (cameraManager.cameraOutputMode) {
switch (self.cameraManager.flashMode) { case .stillImage:
case .Off: cameraManager.capturePictureWithCompletion({ (image, error) -> Void in
sender.setTitle("Flash Off", forState: UIControlState.Normal) if let errorOccured = error {
case .On: self.cameraManager.showErrorBlock("Error occurred", errorOccured.localizedDescription)
sender.setTitle("Flash On", forState: UIControlState.Normal) }
case .Auto: else {
sender.setTitle("Flash Auto", forState: UIControlState.Normal) let vc: ImageViewController? = self.storyboard?.instantiateViewController(withIdentifier: "ImageVC") as? ImageViewController
} if let validVC: ImageViewController = vc {
} if let capturedImage = image {
validVC.image = capturedImage
@IBAction func recordButtonTapped(sender: UIButton) self.navigationController?.pushViewController(validVC, animated: true)
{ }
switch (self.cameraManager.cameraOutputMode) { }
case .StillImage: }
self.cameraManager.capturePictureWithCompletition({ (image) -> Void in
}) })
case .VideoWithMic, .VideoOnly: case .videoWithMic, .videoOnly:
sender.selected = !sender.selected sender.isSelected = !sender.isSelected
sender.setTitle(" ", forState: UIControlState.Selected) sender.setTitle(" ", for: UIControlState.selected)
sender.backgroundColor = sender.selected ? UIColor.redColor() : UIColor.greenColor() sender.backgroundColor = sender.isSelected ? UIColor.red : UIColor.green
if sender.selected { if sender.isSelected {
self.cameraManager.startRecordingVideo() cameraManager.startRecordingVideo()
} else { } else {
self.cameraManager.stopRecordingVideo({ (videoURL) -> Void in cameraManager.stopVideoRecording({ (videoURL, error) -> Void in
println(videoURL) if let errorOccured = error {
self.cameraManager.showErrorBlock("Error occurred", errorOccured.localizedDescription)
}
}) })
} }
} }
} }
@IBAction func outputModeButtonTapped(sender: UIButton) @IBAction func outputModeButtonTapped(_ sender: UIButton) {
{
self.cameraManager.cameraOutputMode = self.cameraManager.cameraOutputMode == CameraOutputMode.VideoWithMic ? CameraOutputMode.StillImage : CameraOutputMode.VideoWithMic cameraManager.cameraOutputMode = cameraManager.cameraOutputMode == CameraOutputMode.videoWithMic ? CameraOutputMode.stillImage : CameraOutputMode.videoWithMic
switch (self.cameraManager.cameraOutputMode) { switch (cameraManager.cameraOutputMode) {
case .StillImage: case .stillImage:
self.cameraButton.selected = false cameraButton.isSelected = false
self.cameraButton.backgroundColor = UIColor.greenColor() cameraButton.backgroundColor = UIColor.green
sender.setTitle("Image", forState: UIControlState.Normal) sender.setTitle("Image", for: UIControlState())
case .VideoWithMic, .VideoOnly: case .videoWithMic, .videoOnly:
sender.setTitle("Video", forState: UIControlState.Normal) sender.setTitle("Video", for: UIControlState())
} }
} }
@IBAction func changeCameraDevice(sender: UIButton) @IBAction func changeCameraDevice(_ sender: UIButton) {
{
self.cameraManager.cameraDevice = self.cameraManager.cameraDevice == CameraDevice.Front ? CameraDevice.Back : CameraDevice.Front cameraManager.cameraDevice = cameraManager.cameraDevice == CameraDevice.front ? CameraDevice.back : CameraDevice.front
switch (self.cameraManager.cameraDevice) { switch (cameraManager.cameraDevice) {
case .Front: case .front:
sender.setTitle("Front", forState: UIControlState.Normal) sender.setTitle("Front", for: UIControlState())
case .Back: case .back:
sender.setTitle("Back", forState: UIControlState.Normal) sender.setTitle("Back", for: UIControlState())
}
}
@IBAction func askForCameraPermissions(_ sender: UIButton) {
cameraManager.askUserForCameraPermission({ permissionGranted in
self.askForPermissionsButton.isHidden = true
self.askForPermissionsLabel.isHidden = true
self.askForPermissionsButton.alpha = 0
self.askForPermissionsLabel.alpha = 0
if permissionGranted {
self.addCameraToView()
}
})
}
@IBAction func changeCameraQuality(_ sender: UIButton) {
switch (cameraManager.changeQualityMode()) {
case .high:
sender.setTitle("High", for: UIControlState())
case .low:
sender.setTitle("Low", for: UIControlState())
case .medium:
sender.setTitle("Medium", for: UIControlState())
} }
} }
} }