Text input box like the SMS app on the iPhone - iphone

I am having a terrible time trying to get an input box like the one in the SMS app.
Can anyone offer some guidance on how to build one of these and make it look good? I need an input box that is shaped nicely like the UITextfield but will stretch vertically when typing.
I assume that I need to calculate width of the text and stretch the overlay image frame vertically when the text word wraps. The closest I have come does stretch but the cursor bounces all around when nearing the boundaries.
UPDATE:
I have worked on this everyday for a week and I have about given up on the UITextView. I can get it to stretch properly but when backspacing, the Textview height shrinks too much when going up a line. As I continue backspacing it corrects itself. For example, it displays this behavior when I am on line 4 and backspace up to line 3. Then as I continue backspacing, it corrects until I get to the end of line 2. Then it corrects itself,.... etc.
I decided to try to subclass UITextField but I can't even get it to display in the Frame size that I specify. 150,150,150,150.

Try Chat Input Sample. It has the similar look and functionality of SMS app.

Three20 project has a control that should do this for you.
From the Three20 README:
TTTextEditor is a UITextView which can
grow in height automatically as you
type. I use this for entering messages
in Facebook Chat, and it behaves
similarly to the editor in Apple's SMS
app.

You get to do this yourself. Luckily, the UITextField can notify you whenever its text changes using UITextFieldTextDidChangeNotification, and luckily NSString has methods (under the UIKit Additions) that let you get the height of the string given a certain width using boundingRectWithSize:options:attributes:context:, and luckily you can resize a UITextField yourself using frame.

I know this is old but for the people that still look at this answer there is now a nice control from Slack that does that called SlackTextViewController.

Related

Text field overlay with back-drop like Clear iPhone app

I've been playing around with JTGestureBasedTableView, but this library only deals with pulling and swiping gesture handling.
I am trying to figure out how the overlay text field input (with translucent background) is implemented in Clear iPhone app (screenshot below). This is the point when you pull down a new cell and it turns into a text field, and once you finish typing in, the content gets filled into the top-most cell, which is presumably hidden behind the textfield.
What is the simplest way to do this?
Here is an excellent tutorial on clear app by Colin Eberhardt .It explains well how the implementation is done

Text Highlighting with the play back sound or voice

i have a requirement to highlight the text when the sound is played in the back ground as like toy story book but i don't have idea how to do it. Some body was telling that calculate the time of each word and do it but it is lengthy process because there are around 50 pages and for each page there is at least 100 words. for calculating the 100 word length and synchronize
the animation with the voice is very typical task. Please if any body have some sample code then please share it. I am in the critical condition at this point i got stuck at this point of time. Please help me.
There are at least two ways for this task:
Use CoreText to implement a custom UIView that display custom format for specific texts based on progress of readings.
Use a UIWebView, populated with content of text, with each text wrapped within tag like <span>. Using JavaScript and CSS to dynamically change the format of the texts based on progress of readings.
Either way you dont need to mess with low level text sizing. You may also consider highlight the text by each paragraph rather than each words, if your requirement permit.

iPhone - Proper UI controls for calculations

I am pretty new to iPhone development and currently working on an application which includes a view that performs a simple numerical calculation. In particular, the user enters 3 or 4 values into text fields and the view displays the result. Something along the lines of http://www.moneychimp.com/calculator/compound_interest_calculator.htm
What is the nicest way to achieve this? I am currently using simple UITextFields and a UILabel for the result but it doesn't look nice or "native-like". What UI object would be best to use?
Thank you!
It's entirely up to you. You're using the right classes for actual input- it comes down to how you choose to style those classes. I'd suggest looking at the documentation for UIView and CALayer (youView.layer, and include QuartzCore framework in your project).
A good start might be to choose a color scheme, a background for your app, and the look and feel you're shooting for- this will inform your styling. Try looking for apps that you think are elegant and attractive, and boil down what they do and what you like about them.
I'd say;
use a grouped table style (with the white tables with round corners on a blueish striped background)
embed settings values directly in the cell (aligned to the right) as much as possible
you can show a relevant keyboard (text, numbers) or picker view to let the user pick values, directly when they tap the cell. Use sliders and switches where relevant.
You may want to take a look at http://www.inappsettingskit.com/, we are currently investigating it for the same purpose and it seems to do the job
You can use either a UISlider or a UIPickerView if some of your values have limits.
You can use UISwitch for toggles.
You can also switch the default keyboard for your textfields to be numeric.
Other than that you seem to be on the right track.
Also, sometimes putting a view inside a scrollview makes things seem cooler even if its only one page. The auto bounce on scrollviews is kind of cool.

iPhone: UITableView number emails style used in Mail app

I am looking for how to style a label in a UITableView cell, so that it shows how many children/messages are in the next view controller.
This is used in Apple's Mail app, to show how many messages are in the inbox or account.
I am sure that this is a UILabel, but what font, color and how to make the oval around it?
The font is surely bold Helvetica because that's what Apple uses everywhere in the iPhone UI. To get the exact color, you could take a screenshot and then sample the color with a color picker. For the rounded corners, experiment with a rather large label.layer.cornerRadius.
Instead of using UILabel.layer.cornerRadius, which results in terrible scrolling performance (as mentioned in my comment), subclass UILabel with a custom drawRect.
Here is the version that I use: http://gist.github.com/500793

iPhone - UITextView should look like a UITextField

I need a textfield so an user could write several lines. Unfortunately a UITextField does not provide several lines, so I think I have to use an UITextView.
But the design of both are not the same.
Is it possible to design the UITextView like the UITextfield standard with white background and rounded corners?
Thanks a lot in advance & Best Regards.
In my self appointed role as interface-nazi, I feel compelled to point out that UITextField and UITextView have different appearances to communicate to users to expect a slightly different function.
In a textfield, a return ends editing. In a textview, it may only create a new line. In a textfield, links and phone numbers are not recognized. In a textview they are. Textviews can scroll. And so on...
You shouldn't create a non-standard interface element unless you have a strong compelling reason to do so. You should ask yourself how making a textview look like a textfield will help the user understand what actions they need to take to make the app work as they expect and wish it to.
Surprisingly small tweaks can create serious user confusion. A non-standard interface can introduce just slight pause, a half second, every time they use it. That minor confusion can degrade their perception of the utility of the app.
You can put a mask image with rounded borders over your textView. Background of UITextView can be changed by standard setBackgroundColor message.
Thanks to Timur here, you can use this chat input sample to implement a multiple line uitextview like what you see in the iPhone messaging app.
It helped me in my app :)
Here how it looks: