Looking at UITextField item in Interface Builder, cannot see any way to set leftView property. Would like the put there an icon to show user that this is place for text input.
The overlay view displayed on the left side of the text field.
#property(nonatomic, retain) UIView *leftView
Can it be set using IB at all?
You mean UITextField? It looks like you cannot do that in IB. Instead, somewhere in your view controller's -viewDidLoad set both leftView and leftViewMode properties.
Related
I have added a tableviewcontroller object for my settings page. On this settings page I have a slider and a UILabel. The UILabel is a number (1-10) which is changed via the slider.
To implement this, I need to create an IBOutlet to the UIlabel, however IB doesn't seem to let me create this. How can I achieve this?
Thanks
you have to create it inside custom class of type UITableViewCell
which should be assigned to that TableViewCell That contain your label.
My Question is : What is the best way to implement "Hiding Keyboard while PickerView (which is inside the PopOver) is Visible"?
What I Want :
I have one view which has around 15 TextFields. Out of 15 , say 7 uses UIPickerView ( that resides into UIPopOverController ) to implement the DropDown Functionality. My Problem is when the KeyBoard is Visible and I Click on the UITextField with UIPickerView, KeyBoard is not hiding. What is the best way to implement this ?
What I Tried :
I tried to implement inputView but it is only used for UIPickerView while I have UIPickerView inside UIPopOverController. I think that's why I am unable to use inputView property. According to this Question, it is Bug from Apple.
Update :
Look , I know that using textField Delegates , we can implement this. But I found inputView property of UITextField and I found it quite interesting as you have to just assign it as :
textField.inputView = pickerView;
But i have the UIPickerView inside PopOver. So How to use this inputView property of UITextField ?
Any Better Idea ?...
I guess you can not do this directly (as inputView). You can try this simple work around:
1) Replace your UITextField with UIButton and connect it to some selector (buttonClicked:). You can use UIButtonTypeCustom to be able to style it so it looks like text field (set layer's bordeColor, borderWidth, cornerRadius, etc..)
2) In this method -(void)buttonClicked:(id)sender - toggle the same UIPickerView you would use as inputView for replaced UITextField. You can make in ordinary instance variable, just remember to set delegate and dataSource. Attach it to the root view (of your UIViewController show in popover) or even UIWindow and animate it in or out (toggle) depending if it is already shown or not.
3) Update button's text (by using [button setTitle:<selected_value> forState:UIControlStateNormal]) in UIPickerViewDelegate method: `pickerView:didSelect...atIndex: - you can additionally hide picker here..
Hope this would help.
Take an object in your .h file as:
id currentTextField;
Implement this UITextField Delegate Method in your .m file:
- (void)textFieldDidBeginEditing:(UITextField *)textField {
currentTextField = textField;
}
Don't forget to make the txtField.delegate = self for all the UITextFields in your file.
Now when you receive the tap on your pickerView Button, first add a statement on that button's click method:
[currentTextField resignFirstResponder];
All the best!!!
I know you can create a UISearchBar, put it in a UIBarButtonItem, and set that as the rightBarButtonItem in code, but I was wondering if there was a way to do that in IB now? Thanks!
You can place an UIView inside UIBarButtonItem. You can then place any UIView subclass into that UIView as subview.
I have created my own UITableViewCell with XIB file. There's an UITextView inside. However, I don't know how to access its features and use its outlets with the UIViewController. What's the way to do it?
alt text http://cl.ly/a13e180c260e5e550b78/content
You can access it by pulling the subview out of the cell's subviews array and casting it to UITextView:
How you created your view hierarchy will determine the index to pass to objectAtIndex.
UITextView *textView = (UITextView*) [cell.subviews objectAtIndex:whateverIndex];
I'd like to create a UIButton with an image that has no borders (a la UIButtonTypeInfoDark) but that highlights when you tap it. How can I do this?
Create a UIButton in interface builder, change the type to custom (and select your image). Add an IBOutlet, then in your viewDidLoad set showsTouchWhenHighlighted to YES.