UIButton not responsive while scrolling - objective-c

I have a subview with a UIButton added to a UIScrollView.
The button is working perfectly as long as the user isn't scrolling.
If the UIScrollView is still scrolling when the user clicks on the button, it just stops the scrolling instead(like if a row had been clicked).
Anyone know how to fix this?

First, make sure this really is the behavior you want - iOS users are used to scrolling views and touching to stop them with a tap without triggering button presses. Non-standard behavior (even when you think its better then the standard behavior) can be confusing to users used to how things work in other iOS apps - it can violate their mental model. Ok, note of caution over.
So how do you fix this? UIScrollView delays sending touch events until it knows if those touches are scroll events. You problem is a user tapping is a scroll event when the UIScrollView is moving. Two possible solutions:
Stop the UIScrollView from delaying any touch events it gets. You can set any scroll views delaysContentTouches to NO, which will stop the delaying action and should allow your buttons to be tapped while scrolling. You can read about it in the UIScrollView class documentation. You will also want to read up on canCancelContentTouches there as well.
Subclass the UIScrollView to add your own logic about where touch events should go. Here is a blog post that discusses how to do this.

Related

Responder Chain (UIWebView inside UItableViewCell) Objective-C

I've been struggling with first responder problem. I put web controller (UIWebView) inside UITableViewCell and now I would like to scroll vertically my table and not affect UIWebView (this case may be done by disabling scrolling scrollview from UIWebView). However problem appears when user zooms into web content, then I want scroll horizontally through web content and still vertically scroll in table (cause cell will be resized to zoomed content).
There is a property called 'multipleTouchEnabled' that should disable the pinch gesture, but I think the user would still be able to double-tap (assuming the cell doesn't consume this gesture). Why not, instead of creating multiple UIWebView's (which have a large overhead) don't you create one hidden UIWebView that loads a website and caches an image, then load this image into the cell.
Ultimately, if you still wanted to use the UIWebView approach, you could probably subclass it and override hitTest/touches methods or handle the gesture recognizers yourself.
Also, if this is for iOS8 I would be using the WKWebView instead.

How to know that User is still touching the screen in UIScrollView?

I have a scrollView. Typical tableView Cell. I did things a lot on viewDidScroll.
viewDidScroll is called on 2 cases.
User scroll
Sometimes user have stop scrolling but the scrollview still scroll anyway due to momentum, bouncing, etc.
So how do I know if users are still touching the scrollView?
UIScrollView has a BOOL property named tracking that is YES while the scroll view has a touch and NO otherwise. In my testing, it is set to NO as soon as the touch ends, even if the view is decelerating (and still sending scrollViewDidScroll: to its delegate). This seems like exactly what you are asking for.
In my testing, the dragging property doesn't seem to become NO reliably while the view is decelerating after the touch ends.
The decelerating property is also unreliable in my testing. If I touch the scroll view while it is decelerating, decelerating remains YES even though the view has stopped scrolling.
The delegate's scrollViewWillBeginDragging: is called when user starts dragging and scrollViewDidEndDragging:willDecelerate: & scrollViewWillEndDragging:withVelocity:targetContentOffset:(iOS 5+ without paging enabled) is called when user lefts his/her fingers.
You may also want to check scrollViewWillBeginDecelerating: and scrollViewDidEndDecelerating:.
Ref: http://developer.apple.com/library/ios/#documentation/uikit/reference/uiscrollviewdelegate_protocol/Reference/UIScrollViewDelegate.html

UIPanGestureRecognizer with UIPageViewController

I am using a UIPageViewController to display certain content. I want to be able to display additional content when the user pulls down on the page using a UIPanGestureRecognizer. I can't seem to figure out what I should add my gesture recognizer to such that it does not cancel any of the pageviewcontroller's actions.
One of the apps I worked on has functionality similar to this. It shows a full-screen UIPageViewController, but if the user drags down on a ribbon on the top right corner, it will slide the whole thing down to reveal a view behind (for settings and other stuff).
I think your problem is that the built-in gesture recognizers are for the page turns. So what you'd want to do is either have something to drag on (such as the ribbon on the top left in my app) that will have its own gestures. OR you can iterate through the gesture recognizers that are assigned to UIPageViewController and get the one that matches the PanGesture, then override it with your own functionality to either delegate the event to the UIPageViewController or do the slide down, based on the type of pan.
Hope that helps.

Multitask gestures not working with alert

After UIViewAlert has become visible, multitask gestures cannot be used. How can I fix it? Is it a normal behavior?
EDIT:
Looks like creating custom view is a good idea. I just wanted to know, if it can be done nice and easily.
When UIAlertView appears, its freeze whole screen. You can't get the touch on screen thats why your gesture is not working. First dismiss the alert view then your gesture will work.
This is normal behaviour, UIAlerts are designed to occupy the whole focus of the device. If you want to allow gestures, try creating your own UIView that overlays on top of your running application.

Showing a keyboard in iOS without animating

Does anyone know if there is a way to show the keyboard in iOS without animating it? Or better yet, can you change the animation speed?
Thanks
The only way I know of, is pushing a view controller which has a view which is made first responder in -viewDidLoad. (viewWillAppear will probably do fine as well)
Pushing it without animation might get you a keyboard popping up without animation.
update too bad, it seems either the view animates into screen (modally or pushed on the navigation stack, with animated:YES) with the keyboard fixed, or the view comes up without animation (i.e. animated:NO) making the keyboard animate into screen again.