iOS: How to code a Tool Tip when user hovers over a UIView - ios

I would like to have a tool tip show up over a set of UIImageView when a user hovers over it. I don't see see any methods to leverage that do this in the UIImageView class.
How can I accomplish this?

Tool tip support is not directly available in iOS at this time. But you can accomplish the same effect with a couple of approaches:
Using an existing tool tip framework
There are open source solutions available that solve the problem, which you can pull into your own project and use and save a lot of time, as long as you ensure the license is compatible with Apple's policies (many of them are, but require that you credit the author somewhere in your project source). You could study their code to learn the technique. For example there is AmPopTip project on github
Here's a corresponding YouTube video:
Here is a similar StackOverflow.com question (there may be more):
Is it possible to show a tooltip in an iOS app?
Trying to code it yourself
You'd probably use a long press gesture, see Apple's Gesture Recognizers documentation and perform some kind of Hit Test to determine when the finger was over UIView subview (in this case UIImageView) and then time the entry of it, and how long it was held in that view without moving out or lifted.
At that point you'd want to overlay a UITextView or a class that contained one but drew a custom border around it, containing with the tool tip by either adding it as a subview over the top or near where the finger was placed, or make it the pop up as a separate UIViewController.

Related

SVProgressHUD iOS8 Replace circle with animation

My Developer is using SVProgressHUD to show loading screen. Is it possible to replace the circle with image animation (a sequence of images)
Using Ashish's suggestion of GifHUD is fine but you could use the UIImageView's animationImagesAPI. You should be able to just set the images and the duration to get the effect you are looking for. Doing so would reduce your 3rd party dependencies from 2 to 0 which is always a win in my book.
This is a question to ask "your developer", not a question to ask the community. Modifying the 3rd party library or implementing custom functionality like this is always possible, but if it should/could be done is dependent on many circumstances.
To directly answer your question, you can just replace the centered animation with a UIImageView and load a series of images into it and start animating it. This is not a difficult task at all. Implementing this into the current library means complications with future maintenance alongside possible other issues.

How do I animate a view on touch?

My scenario is common I think. I want to animate a focus reticle (just like Apple's default app and some of the other camera apps out there). Is this all done in drawRect:? Or can I use the animation framework right from the touch handler?
Following some of the examples around github (and the internet) I went ahead and just subclassed UIView (drawRect:) and a little simplistic "animateWithDuration:".

The Correct Way to do Custom Keyboards in iOS?

I am looking to implement a custom toolbar that sits above my keyboard for a text field with some custom values. I've found a ton of tutorials online but this question is for asking what's the best way to do this.
This tutorial here http://blog.carbonfive.com/2012/03/12/customizing-the-ios-keyboard/ provides the most common way I can see across many tutorials, with creating a new subclass of UIView and using delegates to get that information across.
That's the commonality. However, I came across this tutorial which in the view controller itself just creates the toolbar, assigns it to the textField inputAccessory and it's good to go. In fact, I tried out the code and without any effort, I have now a custom keyboard.
http://easyplace.wordpress.com/2013/03/29/adding-custom-buttons-to-ios-keyboard/
This just seems a bit too easy to me though and I'd think the proper, Apple recommended way would be to create that UIView subclass and use delegates so that the view controller with the text fields acts as that delegate.
I'm specifically targeting iOS 7 in my app.
What are people's thoughts on this? If the second easier link is supported and is likely to pass Apple's guidelines, it's a good starting point but if delegates are the way to go, I'd rather look into that from the start.
Your thoughts will be appreciated.
There is no 'Apple Approved' way to do this, and its hard to believe anything you do here would get your app rejected. The custom keyboard you reference in your post has the iOS6 look and will appear outdated in an iOS6 app. I'll mention some iOS7 suggestions shortly, but the constant danger of mimicking what the System looks like today is guaranteed to look outdated later. In Mac/Cocoa development, Apple use to say at the WWDC that if you did something custom, make it look custom, don't take a standard Apple widget and try to duplicate it. But that advice is mostly ignored.
For iOS 7, you can create buttons that appear just like the system ones do (not pressed), but of course when someone presses them, they won't act like system buttons (i.e. animate up and "balloon" out.
I'm currently using a fantastic add-on keyboard, my fork of KOKeyboard (which uses the buttons above). This is such a cool addition. While the buttons look like iPad buttons, each one has 5 keys in it. By dragging to a corner you select one of the four, and tapping in the middle gives you that key. This might be overkill for your app, but it really helped me with mine. It looks like this:
(the Key / Value is in the under laying view.) The center control lets you move the cursor - its like a joy stick - and can be used to both move and select text. Amazing class, I wish I'd invented it!
Also, for any solution, you want to use a UIToolbar as the view holding the keys, for the reason that it supports blur of the view it overlays, just like the keyboard does. You can use the UIToolbar with no bar button items in it (if you want), and just add subviews. This is a "trick" I learned here, as there is no other way to get blur!
David's KOKeyboard (er…, the one he used - see David's comment below) looks nice. I suspect that he is using the official Apple mechanism:
inputAccessoryView
Typically, you'd set that value on a UITextView, but it can be any class that allows itself to become the first responder.
The provided view will be placed above the default apple keyboard.
It is correct that there is no official mechanism (and it is suggested against) to modify any system provided keyboard. You can add to it, as above. You can also entirely replace it for with your own mechanism. Apply will forgo the keyboard setting on your view and use a custom input mechanism if you set
inputView
set it to any view - Apple will still manage its appearance and dismissal as it does the custom keyboards.
Edit: Of course, iOS 8.x added significant access to keyboards. (not mentioned here)

MPMoviePlayerController controls hide \ show notification?

How can I detected when user touch to hide or show the MPMoviePlayerController controls ?
Is there a notification or other way ?
The official answer would be; not possible.
Reasoning:
The MPMoviePlayerController is to be regarded entirely opaque and should not be modified / accessed other than the documentation supports.
From its reference:
Consider a movie player view to be an opaque structure. You can add
your own custom subviews to layer content on top of the movie but you
must never modify any of its existing subviews.
However, you may get away by adding you own gesture recognizer to the view hierachy exposed by that controller. Make sure that your newly introduced gestures dont interfere with the existing (requireGestureRecognizerToFail etc.).
But note, that is subject to break on every new iOS release as you will need to modify its existing gesture recognizers and that might be considered as a dealbreaker for submitting to iTunes. From my personal experience, that is not commonly detected by apple's review team and therefore could be an option.
The only "perfectly legal" option you have is disabling the control interface altogether (setting MPMovieControlStyle, to MPMovieControlStyleNone) and adding your own, resembling the original interface as far as you need it. Note that the complete functionality of that original interface is not entirely trivial - plan more than a day for that task. I have done loads of stuff like that and I can tell you that even after that experience, I would plan a week for fully implementing those things.

iOS: Facebook chat heads behaviour and animations

This question is probably a little out of date, but I've been using the new Facebook for iOS with the "chat heads" feature (with the chat heads only present within the app), and was wondering how Facebook went about implementing this? E.g. How did they handle the drag animations for the chat heads, and also (when clicking on the chat head) how did they manage to overlay a UITableView on top of the "base" UIViews in the background?
Is this all part of UIKit, or did they create their own classes to handle this?
To answer #StuartM's question in the comments, in the last couple of months I've had a bit more experience with UIKit, and I think I have a rough idea on how I would implement something like this if I was going to do it.
What I would do is for the chat head, create a styled UIButton and add it as subview to the main Window. For the dragging, I would add a Gesture Recognizer to the UIButton to respond to the drags, and for the "snapping to edges" I would use iOS 7's new UIKit Dynamics (http://www.raywenderlich.com/50197/uikit-dynamics-tutorial).
As for showing the UITableView overlay with the chat history, I would use a Child View Controller (https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html#//apple_ref/doc/uid/TP40007457-CH18-SW6) and as for the popping open animation, I would just use the default UIView animations, maybe using animation transactions as I'm not sure I can do everything with just the implicit animations?
And I think that should be it. To be honest, I think anyone who has a handle on those frameworks should be able to build anything in their iOS apps, and if you were to create a "chat heads" like sample project in your spare time, should give you a pretty indepth knowledge of how those frameworks work.

Resources