How can I implement an autoselection textbox like the one for e-mail addresses on the iPhone? - iphone

On the iPhone's mail app, you can type in multiple mail addresses...and then to delete one you just tap it, and click Del. How can I implement something similar in my app? I tried to handle the tap on a UITextView, but it looks like the touchesBegan and related delegate methods are not fired for this class and its subclasses :(
Any idea?

I have implemented a view that is identical to what is found in the mail.app. I used a composite view comprised of a custom UIView which houses a couple of other types of views. I used a UITextField for the text entry. As the user completes an address I take the text and place it in a button with a custom background image (to get the bubble around the text look) and move the UITextField to the right (or to the next line as the case may be). When the user taps one of the address "bubbles" it is selected. If they hit the delete key I remove that bubble from the view and re-layout everything. This is a non-trivial view to build with lots of fun edge cases.

Check out Joe Hewitt three20 project, it includes "Better text fields" which can do such thing.

This could be helpful: Link
TITokenFieldView
A control which mimics the To: field in Mail and Messages. Kinda like an NSTokenField.

Related

Add TagList in UITextField similar to native IOS Message App

In Native IOS Message App, In Adding contact from Address Book, there is one UITextField (might be) which will show added contacts as TagList. How can we create this? i mean, How to add Taglists in UITextField? A screenshot below may give an idea abou my question.
Here is a couple of ready solutions on cocoa controls
token fields
You can create a custom UIView class and bind delegate ,methods to add a Tag and remove a Tag. Inside this view, each tag can be a UILabel or UIButton, and the UITextField is always pushed to the right, next to the last tag.
The important thing is, there's only 1 text field which will move along (the cursor blinking).
Hope it helps!

how to detect a password text field when running in the background?

I am developing a screen recorder and facing a crazy requirement. My boss would like to have an option for a user to automatically pause recording when the current view has a password field. (That view might belong to a third-party app.)
So, is it possible to check if the topmost view has any password text field?
This is an enterprise app so private api is allowed.
Any pointer from jailbreak community is also welcome.
It would be much easier if you could just use your own views but this should work for either your own views or a third party view. BUt anyway, every time you would load up a UIView check all of its subviews, in the ViewDidLoad Method i would think and for each subview check for its class type in your case it would be UITextField. Since these are the only textfields where you can set secure text entry as its text type. Every time you find a UITExtView check if its secureTextEntry is equal to TRUE. If it is true disable the recording until that view is removed from the screen. That should be what you need.

How do I make an editable detail view on the iPhone with a grouped UITableView?

I want to make a grouped TableView similar to the Apple iPhone contacts application.
I need a lot of standard fields which can be edited, but I would only like them editable once the edit button in the navbar is clicked.
This has been bothering me forever that I could not find a good tutorial.
Thanks in advance.
This is not easy. I just built the same thing because there is nothing available from Apple. I ended up creating a single table cell with a UILabel and a UIView on it. The UILabel is for when the cell is in read mode, and the UIView is for editing. The UIView contains a number of UITextFields. These are the individual fields. I also had to implement drawing code to draw the lines between the fields. Then I had to come up with the code to pass in an address object, load it into the fields, format the text for the label, switch in and out of editing mode (with animation), and finally handling saving of changes and canceling. As yet it doesn't handle tapping the address type to select that from a popup list, but I have most of the code in place for the rest.
This could have been done using individual table view cells for each field. But then you can't select the whole thing the way it does in contacts and adding and deleting addresses becomes trickier.

Focus and zoom in on a UITextField when touched?

How in the world does one get the iPhone view to zoom in on a focused UITextField? I need to tap on a text field that I want to edit, and my view should zoom in to the tapped text field and pull up the keyboard (which it already does), similar to how many Internet text fields gain focus on the iPhone. Is this some type of overlay?
I've been looking everywhere for this solution but maybe I've just got the wrong terminology. Thank you in advance.
Could be a duplicate of this StackOverflow question.
In essence, there are a number of ways, but you have to program this effect manually. A textfield is already an overlay. You can either move it, or scroll the containing view.
Please follow the following steps.
Implement the delegate method for all textfield.connect the outlet of textfield in interface builder basically it's setting the delegate property.then in delegate property you can defined the method whatever you want to implement or wanted to do functionality.
Thanks

Best way to allow text edit completion on a complex iPhone UI

I have a somewhat complex iOS view hierarchy. One piece of text is an editable UITextField. When the user touches it, it becomes first responder, and is editable.
Here's the rub, though: Best practice should be that a touch anywhere outside the edit control causes it to resign first responder and end editing. What's the best way of accomplishing this?
Techniques I've tried:
Use the exclusiveTouch property, which stops the user from interacting with other controls, but doesn't cause editing to end. Also disallows user from interacting with my toolbar "Done" button.
Put a see-through UIView under the text field control and on top of everything else (except the toolbar), and use touches there to end editing. This works, but I end up reparenting the text field onto this other random view which sits above my whole hierarchy, which means I have to take care of the text field's layout in multiple places, since it no longer lives in the place where it lived originally, and I have to delegate all its behavior back and forth from its "shield" view to its native home container, which has all the related logic.
Is there an elegant solution to this problem that I'm missing? I figure it must be a common design issue.
Thanks.
Tile 4 "see-thru" views around the textview to capture/ignore touches. Doesn't require modifying or "lifting" the textview, and can be added to the parent view in a fairly modular way.
You can't mask a region without knowing what that mask will cover and what the mask will not cover. So any solution will require enough reach to gather both of those bounds. Either pass the text rect up, or the view rect/region to be disabled down, or both to something in-between. The controller for the stuff to be covered seems as good a place as any to consolidate both rects or regions, if not the controller for the text view.
The nub of the issue is what constitutes "best practice". The fact that the keyboard remains unless the user dismisses it is deliberate. For example, many apps need the user to be able to tap a button while still working in a text field.
The keyboard has a Return button. "Best practice" is to respond to the user tapping that button by resigning first responder. Otherwise, you should leave the keyboard there, since that's what the user expects.
However, if you insist on doing it your way, there's a simple solution: put a UITapGestureRecognizer on the background view. Its handler will be triggered if the user taps on the background or on any button or similar in the interface. So, presuming you have kept a record of what the first responder is, you can send resignFirstResponder to the first responder in the tap gesture recognizer's handler.
If you change your base view to a UIControl you can add an IBAction to that layer that resigns your text field as first responder.
Also, if you have multiple touch events, make sure they each becomeFirstResponder when touched.
I'd love to have some more details to qualify my explanations xD