touchesBegan method is not being called - cocoa-touch

I am trying to detect touches, but the touchesBegan method is not being called.
In my ViewController, I have added the touchesBegan method. My Nib files owner is set to the correct V.C. The Nib itself consists of the view, with a scroll view and a tab bar. Nested in the scroll view is an image view, which has user interaction enabled. What is precluding touches from being registered, or preventing my implementation of touchesBegan from being called?
I've scoured the Internet and Apple docs, and I can't see what I am doing wrong. Also, I'm not really sure what code I can post here to help with my query. Thanks.

Okay, after a lot more reading, I've now got a scrollview and a imageview, both of which are created programatically. The imageview is a sub view of the scrollview, and scrollview has been subclassed so that the touches ended method can decide whether it was a single touch, in which case call the touches ended method from the view controller, otherwise call its supers method. This works just fine, however, why is it that this cannot be done without subclassing scrollview? Is it my lack of understanding of how scrollview works, or is it just a limitation of it?

Related

UIScrollView is not passing touches to subviews in iOS8

I've tested the same code I'm using now in iOS7 and it works fine, but in iOS8 my scrollview appears to not be passing touch events to subviews. I have a view structure like this:
- UIScrollView
- UIView
- buttonView
I've subclassed each of the above views and added the touchesBegan:, touchesCancelled:, touchesShouldCancelInContentView, touchesShouldBegin: methods to each and the only view that ever registers anything is the UIScrollView. Also the only method that executes on the UIScrollView subclass is touchesBegan:. No other delegate methods are fired. This didn't happen in iOS7 with the same code, but it's happening now in iOS8. Can anyone tell me what may have changed that would cause this behavior or even better a fix. I've looked at many posts on this topic, but the standard answers have not done anything.
I've tried changing delaysContentTouches and CancellableContentTouches to no avail.
Thanks for any help.

UIWebView redraw on rotate

I have implemented a UIWebView object into a custom UIView (TSAlertView). My UIWebView sits in the middle of the UIView, as a subview.
When I rotate the iOS device screen, the UIWebView object redraws right on top of the old one, without deleting the old one. All the other elements of this custom UIView are destroyed and redrawn when the screen is rotated.
I imagine I must have missed some sort of procedure for deallocating resources or removing the UIWebView from view. I have tried adding 'autorelease' to the declaration of the UIWebView, but to no avail. I wonder if this is a common symptom of a simple oversight I have made in the way the UIWebView is created?
This seems to be a simple case of not telling the UIWebView object it should destroy itself before it is redrawn on each rotate - but I don't know how I can go about this...
Any wisdom gratefully received.
Ideally while rotating you should not create the views again. Instead you can rearrange the frame in delegates appropriately. In your case you might be creating a UIWebView again, which should be avoided. Instead of that, you can keep it as a class level param(Declare in .h file) and adjust the frame in delegate methods for rotation. Also please note that release/autorelease wont remove your view from superview. You need to call removeFromSuperview method to achieve that.
Check this for view resizing and layout handling

Custom segue - Individually animate UINavigationBar and UITableView

Is there a way to use custom segues to individually animate several different subviews.
For example, I want my modal view to appear by the UINavigationBar fading in (as the source destination's UINavigationBar fades out) and then a UITableView to slide down the screen 'over' the source destination's view controller.
When I try to implement this in the - (void)perform method. My properties don't animate using [UIView animateWithDuration: animations: completion:].
Can anyone provide me with a solution?
Thanks in advance!
You can certainly use custom segues to achieve this - however, I don't think you'll get much help without more details about the setup of your view controllers.
Everything you describe is correct: to create a custom segue you animate the views inside your sourceViewController and destinationViewController inside the segue's perform: method. If they're not animating you might want to check that your segue is actually getting called (you can use breakpoints in the debugger to check this), or that the views you're trying to access inside your view controllers actually exist at that point in time (again, something you can check using the debugger).
For a solution specific to your app you're almost certainly going to have to provide more details about the two view controllers you're trying to transition between. Perhaps you could post your perform: method.

Subview of Scrollview doesn't register touch events

I'm struggling with this problem, and although there are quite some threads on this issue I've not figured it out yet.
I want to load a button into a subview of a scrollview. If I test this subview alone, the button works fine. Also, when I add the button to the scrollview directly, it works fine. But the two combined I don't get any touch event on the button.
My view hierarchy:
UIScrollView
UIView
UIButton (A)
UIButton (B)
So button B works fine, A doesn't.
I've tried messing around with the attributes like Cancellable Content Touches, but so far no luck. I'm loading the subview from the storyboard with:
ViewVC *viewVC = [self.storyboard instantiateViewControllerWithIdentifier:#"ViewVC"];
From the posts I've read, this should just work, so either I'm missing something vital, or I've messed up some attributes along the way. Should I use a delegate to pass the events, or should this be done automatically?
Give your views some colours, and check if one of them is obscuring the other preventing it from being touched. Maybe you UIView is overlapping your UIButton(B), preventing it from being touched.
How are you sure you're adding it?
Make sure you're calling addSubview: on your UIScrollView with your subview as the parameter?

Hittest for backBarButton Item, UIBarButtonItem

I'm trying to determine when a UIBackButton is pressed in a sublayer of a navigation app. Would HitTest be used for that? I've seen reference to HitTest, but not exactly sure what it is and how to code for it. Any help is muchly appreciated. Thanks!!
No. Hit testing is the (recursive) process by which UIKit determines which view receives touch events. You shouldn't need to participate in it or invoke it.
If you're using a UINavigationController, it will do the right thing to transition between view controllers when the back button is pressed. If an individual view controller needs to know when it is transitioning off-screen, it should override the -viewWillDisappear: and -viewDidDisappear:. See the documentation for those methods for more information.