diff --git a/YCameraViewController/YCameraViewController.m b/YCameraViewController/YCameraViewController.m old mode 100755 new mode 100644 index 4a6eb5c..b6ddcb4 --- a/YCameraViewController/YCameraViewController.m +++ b/YCameraViewController/YCameraViewController.m @@ -20,6 +20,8 @@ @interface YCameraViewController (){ @implementation YCameraViewController @synthesize delegate; +static NSString * nibName = @"YCameraViewController"; + - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; @@ -29,6 +31,25 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil return self; } +//Designated initializer. External classes should not need to know the nib name to instantiate the CameraController, so we define it internally +-(instancetype)init +{ + //when using frameworks, the bundle needs to be specified + NSBundle * bundle = [NSBundle bundleForClass:self.class]; + + self = [super initWithNibName:nibName bundle:bundle]; + if (self) { + // Custom initialization + } + return self; +} + +//Hide status bar. otherwise, it will interfere with camera UI. +-(BOOL)prefersStatusBarHidden { + + return YES; +} + - (void)viewDidLoad { [super viewDidLoad]; @@ -584,15 +605,27 @@ - (IBAction)toogleFlash:(UIButton *)sender{ #pragma mark - UI Control Helpers - (void)hideControllers{ [UIView animateWithDuration:0.2 animations:^{ + //1)animate them out of screen self.photoBar.center = CGPointMake(self.photoBar.center.x, self.photoBar.center.y+116.0); self.topBar.center = CGPointMake(self.topBar.center.x, self.topBar.center.y-44.0); + + //2)actually hide them + self.photoBar.alpha = 0.0; + self.topBar.alpha = 0.0; + } completion:nil]; } - (void)showControllers{ [UIView animateWithDuration:0.2 animations:^{ + //1)animate them into screen self.photoBar.center = CGPointMake(self.photoBar.center.x, self.photoBar.center.y-116.0); self.topBar.center = CGPointMake(self.topBar.center.x, self.topBar.center.y+44.0); + + //2)actually show them + self.photoBar.alpha = 1.0; + self.topBar.alpha = 1.0; + } completion:nil]; } diff --git a/YCameraViewController/YCameraViewController.xib b/YCameraViewController/YCameraViewController.xib index fea0f4d..4759a1e 100755 --- a/YCameraViewController/YCameraViewController.xib +++ b/YCameraViewController/YCameraViewController.xib @@ -1,202 +1,677 @@ - + - - + + + - - - - - - - - - - - + + + + + + + + + + + - - + + - - - + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -205,4 +680,4 @@ - \ No newline at end of file + diff --git a/YImagePickerDemo/YImagePickerDemo/ViewController.m b/YImagePickerDemo/YImagePickerDemo/ViewController.m index 4a064c6..0bd2633 100644 --- a/YImagePickerDemo/YImagePickerDemo/ViewController.m +++ b/YImagePickerDemo/YImagePickerDemo/ViewController.m @@ -29,7 +29,7 @@ - (void)didReceiveMemoryWarning #pragma mark - Button clicks - (IBAction)takePhoto:(id)sender{ - YCameraViewController *camController = [[YCameraViewController alloc] initWithNibName:@"YCameraViewController" bundle:nil]; + YCameraViewController *camController = [[YCameraViewController alloc] init]; camController.delegate=self; [self presentViewController:camController animated:YES completion:^{ // completion code diff --git a/YImagePickerDemo/YImagePickerDemo/YCameraViewController/YCameraViewController.m b/YImagePickerDemo/YImagePickerDemo/YCameraViewController/YCameraViewController.m index 0be9e21..e8ff689 100644 --- a/YImagePickerDemo/YImagePickerDemo/YCameraViewController/YCameraViewController.m +++ b/YImagePickerDemo/YImagePickerDemo/YCameraViewController/YCameraViewController.m @@ -12,6 +12,7 @@ #define DegreesToRadians(x) ((x) * M_PI / 180.0) + @interface YCameraViewController (){ UIInterfaceOrientation orientationLast, orientationAfterProcess; CMMotionManager *motionManager; @@ -21,6 +22,8 @@ @interface YCameraViewController (){ @implementation YCameraViewController @synthesize delegate; +static NSString * nibName = @"YCameraViewController"; + - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; @@ -30,6 +33,25 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil return self; } +//Designated initializer. External classes should not need to know the nib name to instantiate the CameraController, so we define it internally +-(instancetype)init +{ + //when using frameworks, the bundle needs to be specified + NSBundle * bundle = [NSBundle bundleForClass:self.class]; + + self = [super initWithNibName:nibName bundle:bundle]; + if (self) { + // Custom initialization + } + return self; +} + +//Hide status bar. otherwise, it will interfere with camera UI. +-(BOOL)prefersStatusBarHidden { + + return YES; +} + - (void)viewDidLoad { [super viewDidLoad];