Skip to content

Commit a9c3888

Browse files
author
yuvraj
committed
Update controller
- Resolve crash issue when Camera access is denied by user. - Update Demo app with Pod dependency.
1 parent 8029021 commit a9c3888

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1402
-2156
lines changed

YCameraView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Pod::Spec.new do |s|
88
s.name = "YCameraView"
9-
s.version = "0.2.0"
9+
s.version = "1.0.0"
1010

1111
s.summary = "Custom Camera Controller similar to the camera View on Instagram."
1212

YCameraViewController/YCameraViewController.h

100755100644
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
UIImage *croppedImageWithoutOrientation;
4545
}
4646
@property (nonatomic, readwrite) BOOL dontAllowResetRestaurant;
47-
48-
@property (nonatomic, assign) id <YCameraViewControllerDelegate> delegate;
47+
@property (nonatomic, assign) id delegate;
4948

5049
#pragma mark -
5150
@property (nonatomic, strong) IBOutlet UIButton *photoCaptureButton;
@@ -61,7 +60,7 @@
6160

6261
@end
6362

64-
@protocol YCameraViewControllerDelegate <NSObject>
63+
@protocol YCameraViewControllerDelegate
6564
- (void)didFinishPickingImage:(UIImage *)image;
6665
- (void)yCameraControllerDidCancel;
6766
- (void)yCameraControllerdidSkipped;

YCameraViewController/YCameraViewController.m

100755100644
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import "YCameraViewController.h"
10+
#import "AppDelegate.h"
1011
#import <ImageIO/ImageIO.h>
1112

1213
#define DegreesToRadians(x) ((x) * M_PI / 180.0)
@@ -166,6 +167,8 @@ +(NSString*)orientationToText:(const UIInterfaceOrientation)ORIENTATION {
166167
return @"UIInterfaceOrientationLandscapeLeft";
167168
case UIInterfaceOrientationLandscapeRight:
168169
return @"UIInterfaceOrientationLandscapeRight";
170+
case UIInterfaceOrientationUnknown:
171+
return @"UIInterfaceOrientationUnknown";
169172
}
170173
return @"Unknown orientation!";
171174
}
@@ -248,8 +251,15 @@ - (void) initializeCamera {
248251

249252
NSError *error = nil;
250253
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:backCamera error:&error];
251-
if (!input) {
254+
if (error) {
252255
NSLog(@"ERROR: trying to open camera: %@", error);
256+
[[[UIAlertView alloc] initWithTitle:error.localizedDescription
257+
message:error.localizedFailureReason
258+
delegate:nil
259+
cancelButtonTitle:@"OK"
260+
otherButtonTitles:nil] show];
261+
[self cancel:self.cancelButton];
262+
return;
253263
}
254264
[session addInput:input];
255265
}
@@ -354,7 +364,7 @@ - (void) processImage:(UIImage *)image { //process captured image, crop, resize
354364
// assetOrientation = ALAssetOrientationUp;
355365

356366
// adjust image orientation
357-
NSLog(@"orientation: %d",orientationLast);
367+
NSLog(@"orientation: %ld",orientationLast);
358368
orientationAfterProcess = orientationLast;
359369
switch (orientationLast) {
360370
case UIInterfaceOrientationPortrait:
@@ -478,7 +488,7 @@ - (IBAction)skipped:(id)sender{
478488
[self dismissViewControllerAnimated:YES completion:nil];
479489
}
480490

481-
-(IBAction) cancel:(id)sender {
491+
- (IBAction)cancel:(id)sender {
482492
if ([delegate respondsToSelector:@selector(yCameraControllerDidCancel)]) {
483493
[delegate yCameraControllerDidCancel];
484494
}
@@ -584,15 +594,27 @@ - (IBAction)toogleFlash:(UIButton *)sender{
584594
#pragma mark - UI Control Helpers
585595
- (void)hideControllers{
586596
[UIView animateWithDuration:0.2 animations:^{
597+
//1)animate them out of screen
587598
self.photoBar.center = CGPointMake(self.photoBar.center.x, self.photoBar.center.y+116.0);
588599
self.topBar.center = CGPointMake(self.topBar.center.x, self.topBar.center.y-44.0);
600+
601+
//2)actually hide them
602+
self.photoBar.alpha = 0.0;
603+
self.topBar.alpha = 0.0;
604+
589605
} completion:nil];
590606
}
591607

592608
- (void)showControllers{
593609
[UIView animateWithDuration:0.2 animations:^{
610+
//1)animate them into screen
594611
self.photoBar.center = CGPointMake(self.photoBar.center.x, self.photoBar.center.y-116.0);
595612
self.topBar.center = CGPointMake(self.topBar.center.x, self.topBar.center.y+44.0);
613+
614+
//2)actually show them
615+
self.photoBar.alpha = 1.0;
616+
self.topBar.alpha = 1.0;
617+
596618
} completion:nil];
597619
}
598620

YCameraViewController/YCameraViewController.xib

Lines changed: 580 additions & 99 deletions
Large diffs are not rendered by default.

YCameraViewDemo/Podfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://github.com/CocoaPods/Specs.git'
2+
platform :ios, '7.0'
3+
xcodeproj 'YCameraViewDemo.xcodeproj'
4+
pod 'YCameraView', '1.0.0'

0 commit comments

Comments
 (0)