Detail disclosure button not displaying in callout view - mapkit

How can I visualize detail disclosure button in callout view for an annotation view ?
The callout now show an info button, that is double-clickable to center the map, but no action on single click ( I performed a segue in my old code when disclosure button was tapped )

I have identified the problem: it was the delegate method that was not called on tap, due to the fact I had added a couple of gesture recognizers to MKMapView , in this way the MKMapView delegate method was not called. I have removed the gesture recognizer when the callout is shown and added again when the callout is hidden. I hope this cane help someone having my same problem.

Related

Bar Button Item : IBAction not fired in View COntroller

At the bottom of the Detail View Controller of a Split View Controller, I have added a Toolbar in the Storyboard. I have added three Bar Button Items in this Toolbar. Each Bar Button Item is hooked to its IBOutlet in the private interface of the Details View Controller, and also hooked to its IBAction implementation in the same controller, for example:- (IBAction)shouldPresentView:(UIBarButtonItem *)sender
The main view contains:
A Webview.
A small rectancgle view at the bottom of the screen, below the webview, created and added programmatically, and containing various buttons. All the buttons stay operational.
When touching any of the Bar Button Items, the button is temporary highlighted, but none of the IBAction methods is triggered (a NSLog() statement in every method is never executed).
After searching and reading equivalent topics, I went through several solutions:
I added manually the Details View Controller as the delegate of the Toolbar in the View Did Load method of the Details View Controller.
I emptied the cache of the Derived Data of the Product.
I checked that every IBOutlet has an address and is not nil.
I tried to add an action SEL manually in the View Did Load method for every Bar Button Item.
I removed the rectangle bottom view to be sure that it was not interfering with the responder chain.
I added a Bar Button Item in the Navigation Bar to check if the same problem occurs: no, the Bar Button Item fires the IBAction method.
Any help would be appreciated.
Developing with iOS 7 SDK in Xcode 5.0.2
The issue was coming from a Tap Gesture that I added to the main view to collect touches on the web view. So the touch on the Bar Button Items was probably captured somewhere by the main view before reaching the UIButtonBarItem. I changed the target of the Tap Gesture to the web view – more logical – and the issue has been solved.

How to swap views, using UIGestureRecognizers

I have set the left back button item of a navigation controller to a custom view and have set up a tap gesture recognizer for it, now when the custom view receives a tap gesture it pops the current view controllers vie of a stack of navigation controllers.
I want to now switch the view when the back button is tapped, and still maintain the functionality similar to a button, like I long press it and it will only pop the current view controller once I have let go.
You can add a UILongPressGestureRecognizer to your custom view in addition to the tap recognizer.
Note that UILongPressGestureRecognizer is a continuous recognizer: one long-press will generate several action messages. You need to check for state UIGestureRecognizerStateEnded in your handler.

iOS perform action before handling touch events

I'm trying to recreate the Facebook slideout menu trick (yes I know there's lots of libraries already).
When a user touches a button on the screen, a new view controller is switched in and a rendered bitmap of the previous screen is shown in the foreground of this new view. The uiimageview has a pan gesture recogniser attached to it to allow it to be moved around on the screen.
Currently it's requiring two touches to activate the gesture recogniser, once to bring in the new view controller, and once for the pan gesture to move the uiimageview.
My question is, on touch down can I bring in the new view controller and then pass the touch events to the uiimageview? Or is there any other trick that will help?
I haven't managed to achieve this exactly, but instead I've subclassed UIViewController so the root view controller never changes, just the content that's being displayed.

Handle tap event by subview of UIScrollView while scrolling

I have custom UIScrollView subclass with some content views inside. In some of them I have UITapGestureRecogniser. All works fine when scroll view is not scrolling. But when it scrolling content views does not receive tap action. What is the simplest solution to handle tap action by subview while scroll view is scrolling?
Details:
MyScrollView scrolls horizontally. It contains a lot of content views (e.g. MyContentView). Each MyContentView has width about one third of MyScrollView width. So there are about 3-4 visible MyContentView elements at a moment. The main behavior of MyScrollView is to 1)make sure that after scrolling one of MyContentView elements will be at center of screen and 2)to scroll to center of MyContentView if user taps on it. So the main answer I hope to get is how to "properly" implement handling of tap action in MyContentView while MyScrollView is decelerating.
I found some same questions and answers but none of them satisfied me. The best was to implement gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: of UITapGestureRecogniser delegate. But in this case I sometimes (when I tap, make smaaaal drag and release finger so tap is steel recognizable(lets called it quasi tap)) have both tap and scroll events and it leads to bugs for me even if scroll view is not scrolling when I begin tap. When user make quasi tap my application tries to scroll to tapped MyContentView element and than immediately handle normal scrolling. It seems even more terrible, due to some other functionality start to perform after handling tap (it must not perform when normal scrolling).
I need solution where scroll view wait enough to decide it is not tap event and only then make scroll. Otherwise if tap event had recognized scroll must not happen.
You can go with the custom delegates methods as well, using #protocol. Implement those delegate methods in view controller where your UIScrollView has been added.
like in MyContentView:
In touchesBegan method,
[self.delegate contentViewTapped:self];
Now in ContainerView class where scroll view is added, implement that method:
- (void)contentViewTapped:(MyContentView *)myContentView {
NSLog (#"ContentView no: %d", myContentView.tag); // if tag has been set while adding this view to scrollview.
}
Go through the examples for #protocol.
Hope this is what you required.
Enjoy Coding :)
This is built into UIScrollView - take a look at the delaysContentTouches and canCancelContentTouches properties. This should alleviate the problem when dragging a small bit after a tap.
This is all system built-in behaviour. I would suggest sticking with what Apple has provided for the feel of your interface (how it reacts to small drags, for instance) so that your app doesn't feel out of place on a user's phone.
EDIT:
Alternatively, you could disable scrolling of your scroll view in you gesture recognizer and re-enable it once it's ended/cancelled.
Further Edit:
I don't understand - I've created a sample project that illustrates how to intercept touches in a subview of a scroll view using gesture recognizer delegate methods. Play close attention to the "Cancellable Content Touches" and "Delays Content Touches" properties of the scroll view. They're both YES for very important reasons.
You scroll view should be delaying content touches until it has determined if the user is attempting a tap, pseudo-tap (as you put it), or a pan for the scroll view. Apple has already written the functionality you're trying to build; UIScrollView will already do what you want.
The problem is that the system doesn't want a scroll view's subviews intercepting tap events while the scroll view is scrolling. To this end, it cancels touch events if it determines that the user is actually trying to pan. Setting "Delays Content Touches" enables this behaviour. Ensure it's turned on and you should be fine.

How to create a button that spawns a movable image? iOS 5

I would like to create a button in my UIView that when touched spawns another button under the finger which immediately starts to follow the finger.
I have seen a tutorial here that deals with button following finger, but i can not figure out how to make this button follow finger WITHOUT user tapping it after creation.
Using iOS 5.1 SDK with XCode 4.3.2
Any help?
You can add target/action pairs to a button for various control events: to make something immediately start following your finger, you probably want UIControlEventTouchDown.
Hook up your first button to call a method on your view controller for that control state. In that action method, create your new button, and shove it in a property on your view controller so that you can refer to it later. Also set a BOOL property on your view controller that's called something like shouldTrackButton.
To make the new button follow your finger, I guess the easiest way is a pan gesture recogniser on the superview. Set that up to call a method on your view controller. In that method, if the gesture recogniser's state is UIGestureRecognizerStateChanged, call translationInView: on the gesture recogniser, passing in the view controller's view (i.e. the superview of the buttons). Now, if and only if shouldTrackButton is YES, take the frame of the original button, translate it by that amount (using CGRectApplyAffineTransform and CGAffineTransformMakeTranslation), and set the new button's frame to the result.
Finally, in the same method, if the gesture recogniser's state is UIGestureRecognizerStateEnded, set shouldTrackButton to NO.