Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert UIImageView in UITextView in the same way that iphone default message (SMS) app uses to insert multimedia content in the UITextView

Tags:

iphone

ios4

ios5

I want to insert UIImageView in UITextView of Toolbar having send and camera button in the same way as iPhone default SMS app do.

like image 535
Piyush Kashyap Avatar asked Apr 16 '12 20:04

Piyush Kashyap


1 Answers

You would be better off using a UIScrollView and managing UITextViews and UIImageViews in it. UITextView doesn't support adding image inline with text. In fact, it doesn't really support anything other than multiline text.

Per your comment below, there are three things I can think of to get the image as part of the text entry box:

  1. They're not using a UITextView, but instead some custom view. That sort of thing is difficult to replicate.
  2. They are overlaying a UIImageView over the UITextView as a subview and setting the contentInset of the UITextView so there is no overlap.
  3. They are using a separate UIView to contain both the UITextView and UIImageView as subviews and simply arrange those subviews as needed.

Both 2 & 3 are very similar (just slightly different approaches) and probably your best approach. Personally, I think 3 is probably the best, since it give you the most control over the position of both views, but 2 should also work fine.

like image 171
Aaron Hayman Avatar answered Sep 22 '22 06:09

Aaron Hayman