Compare commits

..

64 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
14 changed files with 1053 additions and 676 deletions

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 = "2.0.1" s.version = "3.0.0"
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.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 => "2.0.1" } 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, '8.0' s.platform = :ios, '8.0'
s.requires_arc = true
s.source_files = 'camera/CameraManager.swift' s.source_files = 'camera/CameraManager.swift'
end end

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

@ -2,24 +2,32 @@
# 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) [![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)
This is a simple Swift class to provide all the configurations you need to create custom camera view in your app. 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, different flash modes, inputs and outputs. It follows orientation change and updates UI accordingly, supports front and rear camera selection, pinch to zoom, different flash modes, inputs and outputs.
Just drag, drop and use. Just drag, drop and use.
Now it's compatibile 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. 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.
## Installation with CocoaPods ## Installation with CocoaPods
The easiest way to install the CameraManager is with: [CocoaPods](http://cocoapods.org) The easiest way to install the CameraManager is with: [CocoaPods](http://cocoapods.org)
### Podfile ### Podfile
If you want Swift 3.0 syntax use:
```ruby
use_frameworks!
pod 'CameraManager', '~> 3.0'
```
If you want Swift 2.0 syntax use: If you want Swift 2.0 syntax use:
```ruby ```ruby
use_frameworks! use_frameworks!
pod 'CameraManager', '~> 2.0 pod 'CameraManager', '~> 2.2'
``` ```
If you want Swift 1.2 syntax use: If you want Swift 1.2 syntax use:
@ -30,16 +38,38 @@ use_frameworks!
pod 'CameraManager', '~> 1.0.14' 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 ## Installation with Carthage
[Carthage](https://github.com/Carthage/Carthage) is another dependency management tool written in Swift. [Carthage](https://github.com/Carthage/Carthage) is another dependency management tool written in Swift.
Add the following line to your Cartfile: 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: If you want Swift 2.0 syntax use:
``` ```
github "imaginary-cloud/CameraManager" >= 2.0 github "imaginary-cloud/CameraManager" >= 2.2
``` ```
If you want Swift 1.2 syntax use: If you want Swift 1.2 syntax use:
@ -51,68 +81,69 @@ github "imaginary-cloud/CameraManager" >= 1.0
And run `carthage update` to build the dynamic framework. And run `carthage update` to build the dynamic framework.
## How to use ## 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 assess to it. 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.addPreviewLayerToView(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 (it will also set corresponding torch mode for video shoot): 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: To check if the device supports flash call:
```swift ```swift
CameraManager.sharedInstance.hasFlash 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: 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 ```swift
CameraManager.sharedInstance.changeFlashMode() 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: 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 ```swift
CameraManager.sharedInstance.showAccessPermissionPopupAutomatically = false 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 customised to be presented on the Window root view controller, for example. 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
var alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .Alert) var alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .Alert)
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (alertAction) -> Void in alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (alertAction) -> Void in
})) }))
let topController = UIApplication.sharedApplication().keyWindow?.rootViewController let topController = UIApplication.sharedApplication().keyWindow?.rootViewController
if (topController != nil) { if (topController != nil) {
topController?.presentViewController(alertController, animated: true, completion: { () -> Void in topController?.presentViewController(alertController, animated: true, completion: { () -> Void in
// //
@ -124,23 +155,23 @@ CameraManager.sharedInstance.showErrorBlock = { (erTitle: String, erMessage: Str
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, error) -> 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, error) -> 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 8 and above. Xcode 6.3 is required to build the latest code written in Swift 1.2. Supports iOS 8 and above. Xcode 7.0 is required to build the latest code written in Swift 2.0.
## License ## License
Copyright © 2015 ImaginaryCloud, imaginarycloud.com. This library is licensed under the MIT license. Copyright © 2016 ImaginaryCloud, imaginarycloud.com. This library is licensed under the MIT license.

View File

@ -12,7 +12,6 @@
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 */; }; 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, ); }; }; 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 */; }; D71DE8981AD677A8001E62F1 /* CameraManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D71DE8811AD677A7001E62F1 /* CameraManager.framework */; };
@ -52,7 +51,7 @@
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>"; }; 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; }; 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>"; }; D71DE8841AD677A7001E62F1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@ -101,7 +100,6 @@
children = ( children = (
454C1F4619E82E2500C81915 /* AppDelegate.swift */, 454C1F4619E82E2500C81915 /* AppDelegate.swift */,
45A23C191A656BE600FB48F3 /* Example app view controllers */, 45A23C191A656BE600FB48F3 /* Example app view controllers */,
454C1F6619E8316A00C81915 /* CameraManager.swift */,
454C1F4A19E82E2500C81915 /* Main.storyboard */, 454C1F4A19E82E2500C81915 /* Main.storyboard */,
454C1F4D19E82E2500C81915 /* Images.xcassets */, 454C1F4D19E82E2500C81915 /* Images.xcassets */,
454C1F4F19E82E2500C81915 /* LaunchScreen.xib */, 454C1F4F19E82E2500C81915 /* LaunchScreen.xib */,
@ -131,6 +129,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D71DE8851AD677A7001E62F1 /* CameraManager.h */, D71DE8851AD677A7001E62F1 /* CameraManager.h */,
454C1F6619E8316A00C81915 /* CameraManager.swift */,
D71DE8831AD677A7001E62F1 /* Supporting Files */, D71DE8831AD677A7001E62F1 /* Supporting Files */,
); );
path = CameraManager; path = CameraManager;
@ -202,14 +201,17 @@
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastSwiftUpdateCheck = 0700; LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700; LastUpgradeCheck = 0800;
ORGANIZATIONNAME = imaginaryCloud; ORGANIZATIONNAME = imaginaryCloud;
TargetAttributes = { TargetAttributes = {
454C1F4019E82E2500C81915 = { 454C1F4019E82E2500C81915 = {
CreatedOnToolsVersion = 6.0.1; CreatedOnToolsVersion = 6.0.1;
DevelopmentTeam = QM7HJTY23M;
LastSwiftMigration = 0800;
}; };
D71DE8801AD677A7001E62F1 = { D71DE8801AD677A7001E62F1 = {
CreatedOnToolsVersion = 6.3; CreatedOnToolsVersion = 6.3;
LastSwiftMigration = 0800;
}; };
}; };
}; };
@ -258,7 +260,6 @@
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 */, 45A23C181A656BDC00FB48F3 /* ImageViewController.swift in Sources */,
454C1F4719E82E2500C81915 /* AppDelegate.swift in Sources */, 454C1F4719E82E2500C81915 /* AppDelegate.swift in Sources */,
); );
@ -315,8 +316,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_ENTITLEMENTS[sdk=iphoneos*]" = ""; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "";
@ -326,6 +329,7 @@
ENABLE_TESTABILITY = 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",
@ -360,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";
@ -369,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;
@ -378,6 +385,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };
@ -387,11 +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; 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_BUNDLE_IDENTIFIER = cameraDemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
}; };
name = Debug; name = Debug;
}; };
@ -399,17 +409,20 @@
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; 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_BUNDLE_IDENTIFIER = cameraDemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
}; };
name = Release; name = Release;
}; };
D71DE89B1AD677A8001E62F1 /* Debug */ = { D71DE89B1AD677A8001E62F1 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
@ -428,6 +441,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.imaginarycloud.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "com.imaginarycloud.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = ""; VERSION_INFO_PREFIX = "";
}; };
@ -436,6 +450,7 @@
D71DE89C1AD677A8001E62F1 /* Release */ = { D71DE89C1AD677A8001E62F1 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@ -451,6 +466,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.imaginarycloud.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "com.imaginarycloud.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = ""; VERSION_INFO_PREFIX = "";
}; };

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0700" LastUpgradeVersion = "0800"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
@ -23,21 +23,21 @@
</BuildActionEntries> </BuildActionEntries>
</BuildAction> </BuildAction>
<TestAction <TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES">
buildConfiguration = "Debug">
<Testables> <Testables>
</Testables> </Testables>
<AdditionalOptions> <AdditionalOptions>
</AdditionalOptions> </AdditionalOptions>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0" launchStyle = "0"
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
@ -55,10 +55,10 @@
</AdditionalOptions> </AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = "" savedToolIdentifier = ""
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES"> debugDocumentVersioning = "YES">
<MacroExpansion> <MacroExpansion>
<BuildableReference <BuildableReference

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,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.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="13F1066" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="bhK-VL-qY4"> <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="6736"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/> <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies> </dependencies>
<scenes> <scenes>

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ class ImageViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
self.navigationController?.navigationBar.hidden = false self.navigationController?.navigationBar.isHidden = false
if let validImage = self.image { if let validImage = self.image {
self.imageView.image = validImage self.imageView.image = validImage

View File

@ -2,6 +2,12 @@
<!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>

View File

@ -7,12 +7,13 @@
// //
import UIKit import UIKit
import CameraManager
class ViewController: UIViewController { class ViewController: UIViewController {
// MARK: - Constants // MARK: - Constants
let cameraManager = CameraManager.sharedInstance let cameraManager = CameraManager()
// MARK: - @IBOutlets // MARK: - @IBOutlets
@ -30,137 +31,130 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
self.cameraManager.showAccessPermissionPopupAutomatically = false cameraManager.showAccessPermissionPopupAutomatically = false
self.askForPermissionsButton.hidden = true askForPermissionsButton.isHidden = true
self.askForPermissionsLabel.hidden = true askForPermissionsLabel.isHidden = true
let currentCameraState = self.cameraManager.currentCameraStatus() let currentCameraState = cameraManager.currentCameraStatus()
if currentCameraState == .NotDetermined { if currentCameraState == .notDetermined {
self.askForPermissionsButton.hidden = false askForPermissionsButton.isHidden = false
self.askForPermissionsLabel.hidden = false askForPermissionsLabel.isHidden = false
} else if (currentCameraState == .Ready) { } else if (currentCameraState == .ready) {
self.addCameraToView() addCameraToView()
} }
if !self.cameraManager.hasFlash { if !cameraManager.hasFlash {
self.flashModeButton.enabled = false flashModeButton.isEnabled = false
self.flashModeButton.setTitle("No flash", forState: UIControlState.Normal) flashModeButton.setTitle("No flash", for: UIControlState())
} }
} }
override func viewWillAppear(animated: Bool) override func viewWillAppear(_ animated: Bool) {
{
super.viewWillAppear(animated) super.viewWillAppear(animated)
self.navigationController?.navigationBar.hidden = true navigationController?.navigationBar.isHidden = true
self.cameraManager.resumeCaptureSession() cameraManager.resumeCaptureSession()
} }
override func viewWillDisappear(animated: Bool) override func viewWillDisappear(_ animated: Bool) {
{
super.viewWillDisappear(animated) super.viewWillDisappear(animated)
self.cameraManager.stopCaptureSession() cameraManager.stopCaptureSession()
} }
// MARK: - ViewController // MARK: - ViewController
private func addCameraToView() fileprivate func addCameraToView()
{ {
self.cameraManager.addPreviewLayerToView(self.cameraView, newCameraOutputMode: CameraOutputMode.VideoWithMic) cameraManager.addPreviewLayerToView(cameraView, newCameraOutputMode: CameraOutputMode.videoWithMic)
CameraManager.sharedInstance.showErrorBlock = { (erTitle: String, erMessage: String) -> Void in cameraManager.showErrorBlock = { [weak self] (erTitle: String, erMessage: String) -> Void in
let alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (alertAction) -> Void in }))
// var alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .Alert) self?.present(alertController, animated: true, completion: nil)
// 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
// //
// })
// }
} }
} }
// MARK: - @IBActions // MARK: - @IBActions
@IBAction func changeFlashMode(sender: UIButton) @IBAction func changeFlashMode(_ sender: UIButton)
{ {
switch (cameraManager.changeFlashMode()) {
case .off:
switch (self.cameraManager.changeFlashMode()) { sender.setTitle("Flash Off", for: UIControlState())
case .Off: case .on:
sender.setTitle("Flash Off", forState: UIControlState.Normal) sender.setTitle("Flash On", for: UIControlState())
case .On: case .auto:
sender.setTitle("Flash On", forState: UIControlState.Normal) sender.setTitle("Flash Auto", for: UIControlState())
case .Auto:
sender.setTitle("Flash Auto", forState: UIControlState.Normal)
} }
} }
@IBAction func recordButtonTapped(sender: UIButton) @IBAction func recordButtonTapped(_ sender: UIButton) {
{
switch (self.cameraManager.cameraOutputMode) { switch (cameraManager.cameraOutputMode) {
case .StillImage: case .stillImage:
self.cameraManager.capturePictureWithCompletition({ (image, error) -> Void in cameraManager.capturePictureWithCompletion({ (image, error) -> Void in
let vc: ImageViewController? = self.storyboard?.instantiateViewControllerWithIdentifier("ImageVC") as? ImageViewController if let errorOccured = error {
if let validVC: ImageViewController = vc { self.cameraManager.showErrorBlock("Error occurred", errorOccured.localizedDescription)
if let capturedImage = image { }
validVC.image = capturedImage else {
self.navigationController?.pushViewController(validVC, animated: true) let vc: ImageViewController? = self.storyboard?.instantiateViewController(withIdentifier: "ImageVC") as? ImageViewController
if let validVC: ImageViewController = vc {
if let capturedImage = image {
validVC.image = capturedImage
self.navigationController?.pushViewController(validVC, animated: true)
}
} }
} }
}) })
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, error) -> Void in cameraManager.stopVideoRecording({ (videoURL, error) -> Void in
if let errorOccured = error { if let errorOccured = error {
self.cameraManager.showErrorBlock(erTitle: "Error occurred", erMessage: errorOccured.localizedDescription) 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) @IBAction func askForCameraPermissions(_ sender: UIButton) {
{
self.cameraManager.askUserForCameraPermissions({ permissionGranted in cameraManager.askUserForCameraPermission({ permissionGranted in
self.askForPermissionsButton.hidden = true self.askForPermissionsButton.isHidden = true
self.askForPermissionsLabel.hidden = true self.askForPermissionsLabel.isHidden = true
self.askForPermissionsButton.alpha = 0 self.askForPermissionsButton.alpha = 0
self.askForPermissionsLabel.alpha = 0 self.askForPermissionsLabel.alpha = 0
if permissionGranted { if permissionGranted {
@ -169,15 +163,15 @@ class ViewController: UIViewController {
}) })
} }
@IBAction func changeCameraQuality(sender: UIButton) @IBAction func changeCameraQuality(_ sender: UIButton) {
{
switch (self.cameraManager.changeQualityMode()) { switch (cameraManager.changeQualityMode()) {
case .High: case .high:
sender.setTitle("High", forState: UIControlState.Normal) sender.setTitle("High", for: UIControlState())
case .Low: case .low:
sender.setTitle("Low", forState: UIControlState.Normal) sender.setTitle("Low", for: UIControlState())
case .Medium: case .medium:
sender.setTitle("Medium", forState: UIControlState.Normal) sender.setTitle("Medium", for: UIControlState())
} }
} }
} }