Can’t tap button after interface rotation - cocoa-touch

I’ve got a view that has to be presented both in landscape and portrait. The transition between different orientations is done by repositioning and resizing the subviews. One of the subviews is a button (plain UIButton with an image background). When the interface rotates to landscape, the button starts misbehaving – it can only be tapped on its left part, the right part does not respond. When I move the button a bit to the left, the tappable part grows. The button should not be obscured by any other view, it’s clearly visible. When I override the hitTest:withEvent: method in the parent view, I see that the taps in the “numb” part of the button result in nil being returned. I think I have seen this behaviour once before, but unfortunately I’ve forgotten the source of the problem :) Any help?

Ah yes, I forgot to resize the view itself. Thus the button was on the boundary of the view and even though it was not clipped, the part lying outside the view frame was not considered for hit tests.

Related

Animate view and set button backgroundimage conflict

I am making a type of drawer animation for iOS where a button tap in one of my views will expand that view over the other views from the bottom up. All is well, except when I want to change the button image after animation. The animation completes but then returns the view to its original position when setting the button image.
Things I have tried:
Using CGAffineTransformMakeTranslation instead of setCenter; this works perfectly, except I want to also add a panGestureRecognizer to interact with the drawer, present, and dismiss it. The transform doesn't seem to play well with this interaction
Adding the buttons programmatically thinking maybe AutoLayout is fussing with this
UIView beginAnimations as well as UIView animateWithDuration and completion block
Setting breakpoints and verifying that the movement of the view is reflected in the frame of the button before the image is changed; button frame is not still in original position, but has supposedly relocated with the view
It shouldn't matter, but my project is using TabBarController. I made a simpler version of what I'm trying to do with just the one view controller and had the same issue. The green view extends beyond the frame of the view controller's view so that when it moves up it reveals what is off-screen.
example: http://i.imgur.com/tRou0Js.png?1

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.

UIPageViewController set additional actions on pan/swipe

I use an UIPageViewController to pan between three views.
I want to blur the background of the third view when I pan from the second to the third view (and vice versa).
Therefore I have attached an additional UIPanGestureRecognizer to the second view.
This UIPanGestureRecognizer animates the alpha-property of an image view which contains a blurred representation of the background image from 0.0 to 1.0 as soon as the right border of the second view has passed the middle of the screen. An additional UIPanGestureRecognizer of the third view does the opposite when I pan from the third to the second view.
Unfortunately this behavior is static. The panning of the UIPageViewController is interactive.
When I want to pan from the second to the third view and the right border of the second view passes the middle of the screen, the burred image view gets visible while I'm panning. But while I'm panning I can change my mind and cancel the transition when I pan back to the original position. The blurred view stays visible although the second (and not the third) view is on screen.
Similar problems occur when I pan very fast a too short distance. The UIPageViewController will move to the third view but the blurred image view stays invisible.
Is there any way to synchronize the transition of the views with the visiblity/invisibility of the burred image view?
The UIPageViewController delegate protocol has two interesting methods:
pageViewController:willTransitionToViewControllers:
pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:
Unfortunately both methods doesn't work for my purposes.
The UIViewControllerAnimatedTransitioning feature of the iOS 7 SDK also seems not to work with the UIPageViewController.
Has anyone an idea?
Sounds like iOS7 feature UIViewControllerInteractiveTransitioning (which also encompasses the associated non-interactive animated transitioning) is indeed what you need. You might consider replacing your UIPageViewController with some other mechanism that can make use of this approach, such as UINavigationController.

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

Laggy UIScrollView

At the moment I'm working on an iPad explore game which has a hexagon tile map.
I've created a UIScrollView that contains a background view (the game map) and buttons in the form of hexagons (for interaction). I add every UIButton to the view via addSubview.
But... when I add more than 100 buttons the view gets laggy (no surprise here). But what should I do to solve this?
Example:
scroll view http://img233.imageshack.us/img233/5527/screenshot2011090110353.png
Adding UIButtons isn't the way to go here. You should probably draw the "buttons" in a custom -drawRect: method and use -touchesEnded:withEvent: to decide what the user wanted to do.