how to write text on selection indicator of uipickerview - iphone

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.

Related

Swift: How to "append" image to my text in uitextfield

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.

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.

iPhone UIButton provide different inset values for highlighted state

I want my titleLabel text move a little down on button tap (i.e. I want to give different inset values for highlighted and default states).
I have custom button background images and the button goes down in highlighted state image but the text on it stands at the same place so it gives a bad effect and looks like the text is seperated from button.
Is there any way to solve this?
Thanks in advance
The easiest way to do this is to put your text on the button's background image.
If you can't do that for some reason you can try to add IBAction on Button down and adjust button.titleLabel.frame.

Can I customize the check mark position in UITableView?

I'm working on a UITable with allowsMultipleSelectionDuringEditing = true, then I get a circle and red checkmark in the table when it is editing:
The problem is, I need to customize the table view cell such that there are some background image for the cell, and I need a larger margin in the left side of the cell. I can customize the cell contentView for the content position, but are there a way I can customize the checkmark and circle position?
I could have implement a customize table view cell with my own multi selection logic and view, but are there a way I can do it with the built-in multi-select implementation? If not, would you recommend a idiomatic way to do it?
it is possible to change the position of the check mark,
Please make a Table View cell XIB and give it a background image and check mark image and a label ..
the hiding and the display of the check mark will be managed by the associated class of XIB.
it will work for you.
** All the best
To answer my own question, you cannot move the red checkmark and circle (editing control) with public API.
You can however, override the UITableViewCell layoutSubviews method. Inside it find the subview which is a "UITableViewCellEditControl", and modify its position as you wish.

editable cell in tableview

I am trying to implement editable cell in tableview, just like what is available in new contact screen in iphone and ipod
Right now I have two labels in a cell, one of which will remain same all the time and the other one will be editable. Do I need to change this label to textfield.
one more thing I also want that when i click one such cell it should pop a picker view and and set the picerview value.
#Umang in order to make your UITableView cells editable I suggest you to give UITextField to your cell....for more help how to do it take help from already asked How to make tableviewcell text editable on touch in iPhone SDK?
Yes you should add a UITextField to the cell if you want to editable. but
from your question i understand that you want to set a piker value to the cell label.
in this case you don't need to change the cell.
you should add the pop the picker in the didSelectRow method, and change the cell label to its result.
if you dont know how just ask and i will try to help.
Yeah, you will need to change it to a textfield. UILabel is non-editable by design.