Text input box like the SMS app on the 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.
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.
- Update a label with speed every x seconds
- Hide a UIButton when another button is tapped
- When does UITableView content size update with row insert/delete animation
- How to pass an XCode variable to the HTML file in resources folder?
- Access to container view controller
- How to check internet connection on iOS device?
4 Solutions Collect From Internet About “Text input box like the SMS app on the iPhone”
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
Try Chat Input Sample. It has the similar look and functionality of SMS app.
You get to do this yourself. Luckily, the
UITextField can notify you whenever its text changes, and luckily
NSString has methods (under the UIKit Additions) that let you get the height of the string given a certain width, and luckily you can resize a
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.
- Draw lines between points(multiple)
- @class May I know the proper use of this
- Scrolling background – Sprite Kit
- -: message sent to deallocated instance
- How to instruct Xcode to use yasm to compile .asm files?
- Class method equivalent of -respondsToSelector:
- can't change the button color when not selected
- Swift – Adjusting fontSize to fit the width of the layout (programmatically)
- Pass parameter on selector of UIButton
- iphone 5 4 inch
- transparent navigation bar ios
- making switch “if” statements
- Calling numberOfRowsInSection: from heightForRowAtIndexPath
- MPMoviePlayerViewController observes '_serverConnectionDiedNotification'
- How to determine the content size of a UIWebView?