UIScrollView - Move keyboard with touch drag like iOS 7 mail app? - ios

I'm curious how iOS 7 mail app is moving and dismissing the keyboard according to user's touch drag on new message screen.
Also it's implemented on comments screen of instagram app.
Can it be implemented through public apis?

UIScrollView has a property called keyboardDismissMode that allows you to set different behaviours. I think this is what you want:
scrollview.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;

In your view controller just using [self.view endEditing:YES]; when the user taps on the view.
For the drag animation you have to use CoreAnimation and gesture recognizer based on keyboard frame.

Related

Disable userinteraction or touches event in UIView but still enable for subview

I have UIView like this.
I need to put my finger on that view and drag along on those button just like playing piano. Problem is that if initial touch point is on the main view and if I drag along, touches event for main view is triggered and my buttons touch events are not triggered.
As a result, I put this.
[self setUserInteractionEnabled:NO];
Problem is that it has disabled my buttons and other subviews. I want to totally ignore touch event, user interaction from main view but allow for all those subview. How shall I do?
You can set up a notification event for keyboardWillShow and inside the target function set [self setUserInteractionEnabled:NO]; for the superView and when keyboardWillHide notification re-enable it. For hiding the keyboard you could use the GO Button or to dismiss the keyboard add an invisible UIButton to the remaining part of the Screen when the keyboardWillShow event is called and use it to resign first responder.
Hope this helps.
You should create a subclass of UIView for your main view. It should overwrite - hitTest:withEvent: returning always the nearest view for a key.
An alternative solution without inheritance is giving all keys an invisible border such that their views cover the complete main view but never returning the main view.

UIButton not responding to touches - no scroll view

This is my view hierarchy. Send arrow is not responding immediately on the device, it takes multiple touches to trigger the action. But on the simulator, it works perfectly fine. There are no explicit gesture recognisers added in any view, no scroll views and the super view does not delay touch events or anything that I'e noticed in similar questions.
EDIT: Action added through the storyboard. I tried for all touch events and for all of them, the touch is non responsive. Only after a few touches, the action is triggered.
Here's the view debug hierarchy.
Is there any reason why the touch trigger is blocked here? I'm stymied. Help?!
Google Maps override the touches of Views.
Use this way to add your Views.
[self.view insertSubview:viewToAdd aboveSubview:mapView_];
If You adding Views for XIB then Send you map view to back.
[mapView_ sendSubviewToBack:YourView];

Make UIControl only accept swipe gestures and pass along touch/tap gestures

I'm developing an iOS 8.1 app for an iPhone 5 in Objective-C using Xcode 6.1.
When a UITextView is clicked, I have an invisible UIControl view that pops up just above the keyboard, so that the user can swipe down from above the keyboard and dismiss the keyboard (and then move the UIControl out of view again). This is working fine. However, this UIControl view that pops up above the keyboard is covering another UITextView such that the covered text view cannot be tapped on. Every time I try to tap on the covered text view (which is visible because the UIControl is not opaque), nothing happens because the UIControl seems to just be taking the taps and not doing anything with them.
My question is, how do I make it so that the UIControl simply ignores taps (letting them go straight through so that the UITextView underneath can accept them), and yet accepts swipes (so that, when it is swiped downward, it can dismiss the keyboard and move out of view)?
I've tried several solutions but haven't found one that will work well for what I want.
Thanks!
This question is similar to yours. Subclass your UIControl and override - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event and call its super variant to pass it up to its view.
There is another way to do this. Change the main view of your UIViewController to a subclass of UIControl instead of UIView. Connect the following IBAction to the view in order to dismiss the keyboard when the background is tapped.
- (IBAction)backgroundTapped{
[self.view endEditing:YES];
}
Apple Documentation - endEditing:
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
Use this event. If tap gesture return no.

In iOS 8 what is the correct way to add a gesture recognizer on everything in my view controller except a button, without adding an additional button?

I have a button that when tapped shows the button text. In iOS 8 what is the correct way to implement a gesture recognizer to my view controller, so that when anything else is tapped besides that button will remove that text. I would like to avoid adding an additional button because I have multiple buttons that I would like to apply this gesture recognizer to in addition.
You could try using touchesBegan - that would capture touches elsewhere, however if you have another UI element in the view that interacts with touch I believe touchesBegan will not be called in that case as the UI element will not pass the touch event on.
Implement it and pop some logging in there and see what's going on. Could be the solution you're after.

How can I require two fingers to scroll between pages of a UIPageViewController using the ‘scroll’ transition style?

I am developing an application for iOS 6 which will not ever be submitted to the App Store.
I’m trying to use UIPageViewController to allow the user to swipe left-to-right between four different view controllers. This works great but in order to allow normal single-finger interaction with each view controller, I’d like to require two fingers to swipe between pages of the UIPageViewController.
The documentation suggests I should be able to do this by customising the UIGestureRecognizer objects found in the gestureRecognizers property of my UIPageViewController. However, this property seems to be an empty array when the transitionStyle is set to UIPageViewControllerTransitionStyleScroll.
If I change the transitionStyle to UIPageViewControllerTransitionStylePageCurl the property contains UIGestureRecognizer objects and I can customise them at will.
Is there any (documented or otherwise) way to achieve what I want using the scroll transition type?
I have solved that with this code if it solves you the problem. UIPageViewController with scroll transition is implemented with a UIScrollView that is a child of the main view of the controller, UIScrollViewController has a panGesture property used to process the touches of the pan so:
for (UIView* view in [editor.view subviews]) {
if ([view isKindOfClass:[UIScrollView class]])
{
UIScrollView* scrollView = (UIScrollView*)view;
scrollView.panGestureRecognizer.minimumNumberOfTouches = 2;
}
}
And that solves the problem!
UIPageViewController.h has the following comment:
// Only populated if transition style is 'UIPageViewControllerTransitionStylePageCurl'.
#property(nonatomic, readonly) NSArray *gestureRecognizers;
Not sure why it's not in the docs.

Resources