I want to draw a focus indicator on camera view - objective-c

I made an application using the camera.
I didn't use the default camera toolbar.
So I add a toolbar on camera overlay view.
I want to draw tap to focus indicator
So I used UITapGestureRecognizer.
Here is the code
UITapGestureRecognizer *focusRect = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(drawFocusRect:)];
focusRect.numberOfTapsRequired = 1;
focusRect.numberOfTouchesRequired = 1;
[cameraPicker.view addGestureRecognizer:focusRect];
[focusRect release];
In the drawFocusRect method
NSLog(#"tapped");
But it dosen't work.
I changed the value of numberOfTouchedRequired, 2;
And it works.
I think that it doen't work when only single-tap
So, how can I implement this single tapping gesture processing method?

I think camera view's focus view at top of all view.
And I think it has single tap action.
So If you want do this, you should read AVCamera demo in WWDC2010.

Related

Detect swipe down and close View with animation Objective C

I have a search button that onClick opens an UIView that covers most of the screen (It's like an UIAlertView). The UIView has as first element an UIImageView 2 UITextView and a close UIButton, what I want to add now is a gesture recognizer that works like this:
When the user drags the UIImageView down it also drags the UIView and it close it.
I tried with the following code in order to detect the Swipe gesture:
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(swipeToDoMethod)];
[swipeGesture setDirection:UISwipeGestureRecognizerDirectionDown];
[[self popupImage] addGestureRecognizer: swipeGesture];
But I don't know how to proceed after this, can someone point me to the right direction in order to reproduce the effect I want?
missing delegate:
....
[swipeGesture setDirection:UISwipeGestureRecognizerDirectionDown];
swipeGesture.delegate=self;
....

Drag And Swap Two UIScrollViews (Hover & Swap Effect)

I am creating a photo editor in my app and working on a multiple picture layout option.
Currently when the user takes a picture, I display their image in UIImageView nested in a UIScrollView. The reason I nest it in a UIScrollView is so I can pan and zoom.
In the situation where the user selects duo layout mode, the app puts 2 images side by side (so 2 UIScrollViews).
If they hold a finger on one UIScrollView I want to raise the UIScrollView up a tad and give it a drop shadow.
I have a long way of doing this, but I was curious if there was anything in the native libraries that will let me automatically create this hover effect for dragging a view class.
Thanks
No, there isn't any preexisting functionality for this. You can add shadow and animate a "lift" motion yourself with something like this:
// define dragged somewhere as the UIView subclass of your choosing
dragged.layer.shadowColor = [UIColor blackColor].CGColor;
dragged.layer.shadowOffset = CGSizeMake(-2, 2);
dragged.layer.masksToBounds = NO;
dragged.layer.shadowRadius = 4;
dragged.layer.shadowOpacity = .7;
[UIView animateWithDuration:.2 delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{self.draggedPhoto.transform = CGAffineTransformMakeScale(1.2, 1.2);}
completion:nil];

Change Gesture Recogniser Position?

I have a gesture recogniser to detect a tap on a UIImageView, however I force a position change of the image when the orientation of the iPad changes but this causes the gesture recogniser to repositioned incorrectly. How can I resolve this?
EDIT:
strapTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(strapTap:)];
[(UITapGestureRecognizer *)strapTap setNumberOfTapsRequired:1];
strapTap.delegate = self;
[leatherButtonedStrap addGestureRecognizer:strapTap];
This above is how I setup the gesture, adding it to my UIImageView. However, something which might cause a stir is that I add the this view to my main view, remove it and then re-add it when the user presses a certain button. Hard for you to understand whats happening unless you saw the entire class, but let me know if this is enough to go on or not.
Make sure when you're calling locationInView: in strapTap: to send the leatherButtonedStrap as the parater:
CGPoint location = [recognizer locationInView:leatherButtonedStrap];
So that the location is relative to leatherButtonedStrap's coordinate system an not it's superview's.

Touch event of a picture without using UIButton

Is it possible to register a touch of a picture without using UIButton? And if it is, how can i do this?
I can just think of changing the background of a button in the code, and then use IBAction to detect the touch.
Btw, sorry for my english.
Sure. You can put a UITapGestureRecognizer on a UIImageView (remember to set the image view's userInteractionEnabled property to YES):
// assumes "myImageView" is your UIImageView that has user interaction enabled
UITapGestureRecognizer * tap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(tap:)] autorelease];
[myImageView addGestureRecognizer:tap];
later in your controller...
- (void)tap:(UITapGestureRecognizer *)recognizer
{
// whatever you want
}
However, you can set up a UIButton to basically be a dumb image. Just set the background image for the normal state, disable all the adjusting on highlighting and touches, and you should have exactly what you're thinking of.
If I've misunderstood what you're getting at, feel free to clarify.

Finger Swipe On iPad Screen

How do i implement and code for recognizing swipes across the screen, and also making it so that if it swipes on a uiimageview then things happen, // code, how can i do this? THanks
Use UISwipeGestureRecognizer. Something like this to detect a swipe on imageView:
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(imageSwiped:)];
swipe.direction = UISwipeGestureRecognizerDirectionRight;
[imageView addGestureRecognizer:swipe];
[swipe release];
Then define a method - (void)imageSwiped:(UISwipeGestureRecognizer *)sender and react to the swipe there.
I suggest you use a UISwipeGestureRecongizer for it, unless you have a very specific gesture to recongize.
Try reading out : Event Handling Guide for iOS from Apple.