Just like Häagen-Dazs' App, I think it just add an animation before the photo iPhone is taking. I have checked UIImagePickerController and it didn't say how to add another picture or animation before the image. I just want to add some interesting things in front of the scene that I'm taking. Could anyone provide any tutorial? Thanks.
add you custom UIView with animation like this into ImagePickerView
_imagePickerCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
_imagePickerCamera.delegate = self;
_imagePickerCamera.showsCameraControls = NO;
_imagePickerCamera.navigationBarHidden = YES;
_imagePickerCamera.toolbarHidden = YES;
_imagePickerCamera.wantsFullScreenLayout = YES;
//create an overlay view instance
OverlayView *overlay = [[OverlayView alloc]
initWithFrame:self.view.bounds];
//set our custom overlay view
_imagePickerCamera.cameraOverlayView = overlay;
overlay.captureButton.frame = CGRectMake(self.view.frame.size.width/2 - 30, self.view.frame.size.height - 60, 60, 60);
[overlay.captureButton addTarget:self action:#selector(captureImageWithButton:) forControlEvents:UIControlEventTouchUpInside];
[self performSelector:#selector(presentCameraView) withObject:nil afterDelay:0.0f];
You can add any overlay view you want using the cameraOverlayView property of the UIImagePickerController class.
Related
for my app I want to create a custom camera overlay and create a UIImagePickerController to start recording video. (below)
- (IBAction)RecordVideo:(UIButton *)sender {
//initialise camera view
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraUI.cameraDevice = UIImagePickerControllerCameraDeviceFront;
cameraUI.showsCameraControls = NO;
cameraUI.navigationBarHidden = YES;
cameraUI.toolbarHidden = YES;
OverlayView *overlay = [[OverlayView alloc]
initWithFrame:CGRectMake(0, 0, 20,20)];
cameraUI.cameraOverlayView = overlay;
[self presentViewController:cameraUI animated:YES completion:nil];
}
as part of the cameraOverlayView I've instantiated a UIButton:
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
//clear the background color of the overlay
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
... some overlay UI stuff
UIButton *captureBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIImage *captureBtnImg = [UIImage imageNamed:#"captureBtn.png"];
[captureBtn setBackgroundImage:captureBtnImg forState:UIControlStateNormal];
captureBtn.frame = CGRectMake(self.frame.size.width/2 - 15,
430,
80,
80);
[self addSubview:captureBtn];
}
return self;
}
So how do I create an IBAction for this button which can then make the UIImagePickerController cameraUI start recording?
If somebody could also explain to me how the IBActions are called from specific buttons only that would also be amazing because that seems like black magic to me?
You can add target like this,
[captureBtn addTarget:self action:#selector(captureBtnclick:) forControlEvents:UIControlEventTouchUpInside];
and you action method shoulbe like this
-(void)captureBtnclick :(UIButton*)sender{
//handle your task on click here
}
second thing why you are adding layer on it? you can use default video recording from imagePicker by setting mediatype like
cameraUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
Update accroding to comment
you can use on button click,
[picker startVideoCapture]; //in your case cameraUI i think
Update 2 :
in your .h file,
#property UIImagePickerController *cameraUI;
then in your method RecordVideo use like,
self.cameraUI = [[UIImagePickerController alloc] init];
self.cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
//etc.....
By this way you can use camaraUI in whole class by self
hope this will help :)
I'm trying to add UIPinchGestureRecognizer to UIImagePickerController to zoom in/out front camera but were not able to call method inside UIPinchGestureRecognizer (handlePinchWithGestureRecognizer). I didn't get any error but also didn't get any interaction.
Here is the code I'm using in viewDidAppear:
_imagePicker = [[UIImagePickerController alloc] init];
_imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
_imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
_imagePicker.allowsEditing = YES;
_imagePicker.showsCameraControls = NO;
_imagePicker.navigationBarHidden = YES;
_imagePicker.view.userInteractionEnabled = YES;
_imagePicker.view.multipleTouchEnabled = YES;
_imagePicker.delegate = self;
UIPinchGestureRecognizer *pinchGestureRecognizer = pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:#selector(handlePinchWithGestureRecognizer:)];
[_imagePicker.view addGestureRecognizer:pinchGestureRecognizer];
[self presentViewController:_imagePicker animated:NO completion:nil];
First of all I wouldn't add gesture recognizers to UIKit View Controllers' views that are not meant to be subclassed. You don't know for sure what's going on in there, and how your recognizer may interfere with the view's standard features.
Secondly, I tried to zoom the front camera on my iPhone and it's not possible to do so.
If you want to get video from the front camera and zoom it you will have to implement your own Controller that takes a video session from the front camera and do the transformations to do the zooming, etc.
I am developing one iPad application using story board.In my view controller one table is set as the left side and one more view is set as the right side.I need to set one activity controller above the right side view.Which need to start animating when i click the right side table cell and need to stop after 1s.I am using 'didSelectRowAtIndexPath' function for select table cell.How i will set activity indicator for my situation.
In didSelectRowAtIndexPath method you could make a call to below function:-
-(void)setActivityIndcator:(UIView *)view
{
transparentView = [[UIView alloc] init];
transparentView.frame = view.frame; //Provide frame of right side view.
transparentView.alpha = 0.5; //To provide transparent look and feel.
activityInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityInd.frame = CGRectMake(transparentView.frame.size.width/2, transparentView.frame.size.height/2, 50, 50); //Change as you want it to be
[transparentView addSubview:activityInd];
[activityInd startAnimating];
[self performSelector:#selector(stopIndicator) withObject:self afterDelay:1];
}
-(void)stopIndicator //This method will be called after delay and would remove view and activityInd
{
[activityInd stopAnimating];
[activityInd removeFromSuperview];
[transparentView removeFromSuperview];
}
Also you could create a subclass of it and use it in any viewcontroller by creating it's object. That why u don't need to write down all function everytime.
use this in this method
didSelectRowAtIndexPath
UIActivityIndicatorView *activityView =
[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityView.frame = CGRectMake(120, 230, 50, 50);
[self.view addSubview:activityView];
Use the delegate method didSelectRowAtIndexPath of TableView and write the following code into it
UIActivityIndicatorView *activity =
[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activity.frame = CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/2, 50, 50);
[self.view addSubview:activity];
[activity startAnimating];
Stope this when your work is done and remove it from the view
On my app, I am trying to initialise and present a UIImagePickerViewController instance of custom size. Basically, I want a square view of size 200x200 to hover over my viewController. I tried out the following code and it still presents the camera overlay in full-screen mode. Any suggestions on how I can achieve a custom frame on my overlay view?
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.delegate = self; imagePickerController.showsCameraControls = NO;
imagePickerController.cameraOverlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[self presentViewController:imagePickerController animated:NO completion:nil];
Any help is appreciated.
You need use cameraOverlayView property. Set to this property your custom view that contains transparent square of size 200x200.
Notice to code that you've provided:
When you create view [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; it uses clear (transparent) colour by default. That's why you don't see it after launching.
Change it's background colour and it will become visible over the camera layer:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
view.backgroundColor = [UIColor redColor];
imagePickerController.cameraOverlayView = view;
You need to look at Face Detection enabling for ios and its API in Apple developer library.
CoreImageFramework provides the API where on detection you can hover .
CIImageFilter, CIFilter methods are used
for Reference please read Apple Documentation and Check the following sample
Square Cam
Using UIImagePIckerController Its Difficult to overlay and Hover on move , Use AVFoundation framework for better Results
I'm trying to modify Apple's PhotoScroller example to make the scrollview that is created into a subview instead of it being a view that takes up the entire screen. Any ideas on how this can be accomplished?
- (void)loadView
{
// Step 1: make the outer paging scroll view
CGRect pagingScrollViewFrame = [self frameForPagingScrollView];
pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
pagingScrollView.pagingEnabled = YES;
pagingScrollView.backgroundColor = [UIColor blackColor];
pagingScrollView.showsVerticalScrollIndicator = NO;
pagingScrollView.showsHorizontalScrollIndicator = NO;
pagingScrollView.contentSize = [self contentSizeForPagingScrollView];
pagingScrollView.delegate = self;
// When I do this it fails
[self.view addSubview:pagingScrollView];
// Step 2: prepare to tile content
recycledPages = [[NSMutableSet alloc] init];
visiblePages = [[NSMutableSet alloc] init];
[self tilePages];
}
You just need to modify the frame of the scrollview to be positioned and sized how you want:
This is the line in the view controller that sets it up in the example
pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
As an example here is a sample frame with some hardcoded values:
CGRect scrollFrame = CGRectMake(100,100,100,100);
pagingScrollView = [[UIScrollView alloc] initWithFrame:scrollFrame];
So, I found out that I was able to add the scrollView as a subview by changing the method from loadView to viewDidLoad.
I have no clue why that works, but it does. I'd love to know why that's the case however...