From c6129f32b8676b7fd2b956740a3b282468089e05 Mon Sep 17 00:00:00 2001 From: AndrewGertig Date: Sat, 8 Feb 2014 21:38:10 -0500 Subject: [PATCH] add notes about building the UI in code not Storyboards --- Gemfile | 2 +- Gemfile.lock | 2 -- Rakefile | 15 +--------- app/AVCamViewController.rb | 60 +++++++++++++++++--------------------- 4 files changed, 28 insertions(+), 51 deletions(-) diff --git a/Gemfile b/Gemfile index b3479f5..b568753 100644 --- a/Gemfile +++ b/Gemfile @@ -3,4 +3,4 @@ source 'https://rubygems.org' gem 'rake' # Add your dependencies here: -gem 'awesome_print_motion' # aliased to ap +# gem 'awesome_print_motion' # aliased to ap diff --git a/Gemfile.lock b/Gemfile.lock index edc3052..9167fdf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,10 @@ GEM remote: https://rubygems.org/ specs: - awesome_print_motion (0.1.0) rake (10.1.1) PLATFORMS ruby DEPENDENCIES - awesome_print_motion rake diff --git a/Rakefile b/Rakefile index 243f775..d8dc316 100644 --- a/Rakefile +++ b/Rakefile @@ -13,20 +13,7 @@ Motion::Project::App.setup do |app| app.name = 'AVCam' app.frameworks += [ 'AssetsLibrary', - 'AudioToolbox', 'AVFoundation', - 'CoreGraphics', - 'CoreImage', - 'CoreMedia', - 'CoreVideo', - 'Foundation', - 'ImageIO', - 'MediaPlayer', - 'MessageUI', - 'MobileCoreServices', - 'OpenGLES', - 'QuartzCore', - 'SystemConfiguration', - 'UIKit' + 'SystemConfiguration' ] end diff --git a/app/AVCamViewController.rb b/app/AVCamViewController.rb index 4bb5656..4654a3a 100644 --- a/app/AVCamViewController.rb +++ b/app/AVCamViewController.rb @@ -99,33 +99,40 @@ def self.keyPathsForValuesAffectingSessionRunningAndDeviceAuthorized def viewDidLoad super #.viewDidLoad - + # Create the AVCaptureSession session = AVCaptureSession.alloc.init self.setSession(session) # Setup the preview view - @previewView = AVCamPreviewView.alloc.initWithFrame(self.view.bounds) - @recordButton = UIButton.buttonWithType(UIButtonTypeCustom) - @recordButton.setTitle("Record", forState:UIControlStateNormal) - @recordButton.addTarget(self, action:"toggleMovieRecording:", forControlEvents:UIControlEventTouchUpInside) - @recordButton.frame = [[32,516], [72, 30]] + # FROM HERE TO... + ######################################################################### + self.navigationController.setNavigationBarHidden(true, animated:false) + + @previewView = AVCamPreviewView.alloc.initWithFrame(self.view.bounds) - @cameraButton = UIButton.buttonWithType(UIButtonTypeCustom) - @cameraButton.setTitle("Swap", forState:UIControlStateNormal) - @cameraButton.addTarget(self, action:"changeCamera:", forControlEvents:UIControlEventTouchUpInside) - @cameraButton.frame = [[216,516], [72, 30]] + @recordButton = UIButton.buttonWithType(UIButtonTypeCustom) + @recordButton.setTitle("Record", forState:UIControlStateNormal) + @recordButton.addTarget(self, action:"toggleMovieRecording:", forControlEvents:UIControlEventTouchUpInside) + @recordButton.frame = [[32,516], [72, 30]] - @stillButton = UIButton.buttonWithType(UIButtonTypeCustom) - @stillButton.setTitle("Still", forState:UIControlStateNormal) - @stillButton.addTarget(self, action:"snapStillImage:", forControlEvents:UIControlEventTouchUpInside) - @stillButton.frame = [[124,516], [72, 30]] + @cameraButton = UIButton.buttonWithType(UIButtonTypeCustom) + @cameraButton.setTitle("Swap", forState:UIControlStateNormal) + @cameraButton.addTarget(self, action:"changeCamera:", forControlEvents:UIControlEventTouchUpInside) + @cameraButton.frame = [[216,516], [72, 30]] - self.view.addSubview(@previewView) - self.view.addSubview(@recordButton) - self.view.addSubview(@cameraButton) - self.view.addSubview(@stillButton) + @stillButton = UIButton.buttonWithType(UIButtonTypeCustom) + @stillButton.setTitle("Still", forState:UIControlStateNormal) + @stillButton.addTarget(self, action:"snapStillImage:", forControlEvents:UIControlEventTouchUpInside) + @stillButton.frame = [[124,516], [72, 30]] + + self.view.addSubview(@previewView) + self.view.addSubview(@recordButton) + self.view.addSubview(@cameraButton) + self.view.addSubview(@stillButton) + ######################################################################### + # HERE, IS ADDITIONAL SINCE WE AREN'T USING STORYBOARDS self.previewView.setSession(session) @@ -281,16 +288,10 @@ def willRotateToInterfaceOrientation(toInterfaceOrientation, duration:duration) def observeValueForKeyPath(keyPath, ofObject:object, change:change, context:context) - NSLog("Observed Value For Key Path: %@", keyPath) - # NSLog("context = %@", context[0]) - NSLog("change = %@", change.to_s) - # if context == CapturingStillImageContext if keyPath == "stillImageOutput.capturingStillImage" isCapturingStillImage = Utils.boolValue(change[NSKeyValueChangeNewKey]) NSLog("CapturingStillImageContext, change New: %@", isCapturingStillImage.to_s) - - # isCapturingStillImage = change["new"].nil? if isCapturingStillImage self.runStillImageCaptureAnimation @@ -299,8 +300,6 @@ def observeValueForKeyPath(keyPath, ofObject:object, change:change, context:cont elsif keyPath == "movieFileOutput.recording" isRecording = Utils.boolValue(change[NSKeyValueChangeNewKey]) NSLog("RecordingContext, change New: %@", isRecording.to_s) - - # isRecording = change["new"].nil? # dispatch_async(dispatch_get_main_queue(), ->{ Dispatch::Queue.main.async { @@ -317,11 +316,7 @@ def observeValueForKeyPath(keyPath, ofObject:object, change:change, context:cont # elsif context == SessionRunningAndDeviceAuthorizedContext elsif keyPath == "sessionRunningAndDeviceAuthorized" isRunning = Utils.boolValue(change[NSKeyValueChangeNewKey]) - NSLog("SessionRunningAndDeviceAuthorizedContext, change New: %@", isRunning.to_s) - # isRunning = change["new"].nil? - - - # isRunning = true + NSLog("SessionRunningAndDeviceAuthorizedContext, change New: %@", isRunning.to_s) # dispatch_async(dispatch_get_main_queue(), ->{ Dispatch::Queue.main.async { @@ -366,9 +361,6 @@ def toggleMovieRecording(sender) # Start recording to a temporary file. # NSString *outputFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:[@"movie" stringByAppendingPathExtension:@"mov"]]; - - NSLog("FilePath needs work") - # outputFilePath = NSTemporaryDirectory().stringByAppendingPathComponent("movie".stringByAppendingPathExtension("mov")) outputFilePath = "#{NSTemporaryDirectory()}movie.mov" self.movieFileOutput.startRecordingToOutputFileURL(NSURL.fileURLWithPath(outputFilePath), recordingDelegate:self)