Add image to UiTextView and post it - iphone

I want to add smily image in UITextview and also some text and then when i press send button all data from Textview i want to post.

you could use a container view that will include your UIImageView for showing the image and UITextField for allowing to enter the text and UIButton button to grab the text.
The below is the approach ... which you can use.
[myContainerView addSubview:myImageView];
[myContainerView addSubview:myTextView];
[self.view addSubview:myContainerView];

Did you Try out this one when you EGOTextView rather than the UITextView... i have tried to search a lot for your answer but need some more time to get it done. in the mean while try that out.

Related

Add More Button in UiButton

I have a long string to show on UIButton. I want to show the first 2 lines and if the text is longer than that - add a More button that will pop up an alertview to show the full text. See the image
What is the best way to do that?
Add your more button and wire it up the standard way, but set it to hidden. Then determine the length of the string and see if it is bigger than your textview. If so, set the more button to visible. When the button is pressed resize the textview and add more lines.
I'm not around a Mac at the moment so don't take this answer as gospel.
I would think that if you added a UILabel as a subview of a UIButton and setup the label to only show two lines before truncating, you could then detect if the displayed text was different than the actual text you used when you created the label by using NSString's isEqualToString: method. If the strings are different you know the label is truncated and you should show the 'more' button. I found this code on StackOverflow that returns an NSString within an arbitrary NSRect.

Hypertext in uilabel or uitextview

Is there any way to make a hypertext in the text for UILabel or UITextView?
It is easy to do with UITextview. You can set the datadetectortype for UITextview.
textView.dataDetectorTypes = UIDataDetectorTypeLink;
You can set any action on lable or textview, don't forget to check "User Interaction Enabled", make it transparent, and open a link on it!
As of now I tried for UILabel hyper link by providing gesture on label and never tried for UITextView.But more convenient way is providing a button with an action method that is easy way.some more details may useful for your work hyperlink providing from the NSString.

Unable to Generate UITextField dynamically in place of UILabel?

I am trying to generate UITextField dynamically in place of UILabel.
Now i want to update that data.
I am displaying data in the UILabel from the database and there is an UIButton for editing.
When i click on that UIButton UITextField should be generated in place of UILabel and also data should be displayed in UITextField.
What you can do is to design a view with all textfield which works in two modes, first readonly (by setting userInteraction to false ) and second editing mode. This way you can avoid the use of labels. This will need only one edit button for all of the fields. if you still want to stick with your approach, you can hide the labels, use their frames to create textfields at their place and make them visible as long as you are working in edit mode. Don't forget to use
[self.view bringSubviewToFront:TEXT_FIELD];
While you add them to your view.
e
Managing the editing with the approach I mentioned earlier is mor easy and require less efforts. Hope it helps
you need to implement this textField in .h file, to get access to it when you finish aditing. Then, in your button callback:
textField = [[UITextField alloc] initWithFrame:[yourUILabel frame]];
[textField setText:yourUILabel.text];
[self.view addSubView:textField];
then, to replace it back:
[yourUILabel setText:textField.text];
[textField removeFromSuperView];
You can use the methods that others have described here but it sounds like you just want a UITextField that looks like a label and you want to control whether or not it's editable.
set enabled to YES / NO depending on whether you want the user to edit the UITextField
set the borderStyle of a UITextField (usually between UITextBorderStyleRoundedRect and UITextBorderStyleNone)
You can then toggle the enabled and borderStyle values as follows:
- on initial view: enabled: NO, border style: UITextBorderStyleNone
- on button tap: enabled: YES, border style: UITextBorderStyleRoundedRect
You don't have to mess with the view hierarchy and worry about frames, etc, this way.

how to write text on selection indicator of uipickerview

how to write text on selection indicator of uipickerview
The simplest approach will be just to add UILabel with your text over the UIPickerView. You only need to find the right coordinates so text will be placed well.
If you want to display text on it try adding a UILabel as a subview to the view containing the picker. You just need to get the frame in the right spot - easy with IB, more trial and error through code. The set label to have a clear background. Just update the label value as needed.

textbox and button does not recognize touch when added as a subview of a label

I am using this to add a text box and a button as a subview of label pLabel.
[pLabel addSubview:pTextbox];
[pLabel addSubview:pButton];
[self.view addSubview:pLabel];
When I run the application, I see both of them, but the text box or the button no longer responses to my touch. Could you please let me know how can I fix this?
Thanks.
pLabel.userInteractionEnabled = YES;
This might not be an appropriate use of labels though. You might want to consider subclassing from something other than UILabel.