How to put a placeholder text besides the text entered by user in the UISearchBar Text.
Or even to put some text in gray if the above cannot work.
You can make gray texl as UILabel and put it on UISearchBar as subview.
Or you can write your own class, subclassing UISearchBar with this functional.
Related
I would like to append an image to my text in uitextfield, and since the text in the textfield is never consistent I cannot use rightview. Any suggestions?
P/S: I used a textfield instead of label because tapping the textfield is supposed to trigger a picker view.
Ahh, after scratching my head for the entire day, I ended up hide the text in my text field and add a uiLabel on top and an imageview beside it with autolayout and update the text.
I understand how to creata UIBarButtonItem with text and make it look like a title. I essentially want one more line of smaller text below that 'explaining' what the big text is.
using initWithCustomView with 2 views seems to get much more complicated because of width.
The only possible solution is to use initWithCustomView method on the UIBarButtonItem and then set the left or rightBarButtonItem property in the UINavigationItem with this bar button.
And to add the obvious, your customView can be the multiline UILabel.
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.
i want to set first text on my UISearchBar -the text is "Search"-, and the text will disappear when user start typing.
just like this:
how it could be.???
thanx
use placeholder property to set your grayish text that get disappears while text is written on it
searchBar.placeholder = #"Search";
[self.searchBar setPlaceholder:#"search"]
that's the placeholder text, you can set it in Interface Builder, or programmatically with UISearchBar's placeholder property
I want to create a text display area (either UILabel or UITextView) in my iPhone app which (1) allows scrolling and (2) does not allow selection. I have tried the following techniques unsuccessfully:
Basic UILabel: Didn't allow
scrolling, and clipped text to the
bottom of UILabel space on screen.
Giant UILabel within a UIScrollView: the UILabel kept placing the text (vertically) at the center of the giant UILabel, so it often was outside of my UIScrollView.
UITextView: So far this approach has worked the best, because it scrolls and does not clip the text. I can even subclass UITextView to enable resizing the text to fit within the textview, and passing any touch events to the superview to detect taps & swipes. But, when the user taps and holds on the text itself, the text selection interface appears. I am not interested in this interface and it actually is distracting from the user's experience. I have tried to subclass canPerformAction:withSender:, but apparently this function is called after the tap event--not before it.
Does anyone know how to disable the text selection interface in UITextView, without also disabling scrolling?
Take option number 2, but set the numberOfLines property on your UILabel to 0. This will set the number of lines to 'unlimited' and prevent the vertical centring of the text.
Don't forget to set the lineBreakMode property to UILineBreakModeWordWrap so that your text doesn't run off the side of the UILabel.