uitextfield

Changing the color of the icons in a UItextField inside a UISearchBar

只愿长相守 提交于 2019-12-01 07:03:28
I'm trying to customise the appearance of the search bar in my search controller. Setting the background and text colors works fine but I just didn't find a way to change the color of the icons in the text field, specifically the magnifying glass and the x button. I've found this Objective-C code which should do what I want but I'm struggling to translate it to Swift: (EDIT: Skip to the first answer for the working Swift 3 solution.) UITextField *searchBarTextField = [self.searchDisplayController.searchBar valueForKey:@"_searchField"]; // Magnifying glass icon. UIImageView *leftImageView =

Attempt to delete row containing first responder that refused to resign

坚强是说给别人听的谎言 提交于 2019-12-01 05:53:55
I have an iOS 6-based project that implements a UITableView . Each cell in the table view contains a UITextField allowing the user to enter information. If the user clears a text field, or deletes all input from the field, (i.e. [textfield length] == 0 ) when they tap onto another cell (text field) it deletes the previous cell (text field) from the table view, as it's empty - this avoids empty cells accumulating in the table view. This is all done using a method called -textFieldEditingDidEnd: which fires on the UIControlEventEditingDidEnd event for the text fields: - (void

How to display this little white x-circle in a UITextField, so users can delete the text?

别说谁变了你拦得住时间么 提交于 2019-12-01 05:44:38
Some apps have this nice little white circle with an gray x in there UITextField. How can I add this to an UITextField and delete the text when it is tapped? To add a button like this, you can use the clearButtonMode property of an UITextField. The code will be like this: // Show cancel button never textField.clearButtonMode = UITextFieldViewModeNever; // Show cancel button only when you're editing text in textField textField.clearButtonMode = UITextFieldViewModeWhileEditing; // Show the cancel button only when you aren't editing the text textField.clearButtonMode =

IOS: UItextfield disabled

一个人想着一个人 提交于 2019-12-01 05:43:40
When we push on a textfield, a cursor appear in this textfield; but I don't want that this cursor appear; then I want make this textfield disabled, where you can't write inside, how can I do? Can you set enabled property/userInteractionEnabled of text field to No in ViewDidLoad() using the code textField.enabled = NO; or textField.userInteractionEnabled = NO; If you're working with storyboards or .nib files and you want it to start out disabled you can also easily uncheck the enabled property in interface builder for some time-saving. 来源: https://stackoverflow.com/questions/5947965/ios

EXC_BAD_ACCESS in UITextField while typing

大兔子大兔子 提交于 2019-12-01 05:12:53
I created a brand new view-based project and added into the viewDidLoad - (void)viewDidLoad { [super viewDidLoad]; myField = [[UITextField alloc] initWithFrame:CGRectMake(50, 50, 150, 31)]; myField.delegate=self; [self.view addSubview:myField]; [myField release]; } my header file is @interface textfieldpracticeViewController : UIViewController<UITextFieldDelegate>{ UITextField *myField; } when i click in the textfield and the keyboard pops up, i start typing but on the 2nd character, i get the exc_bad_access error. I ran it with NSZombieEnabled, NSDebugEnabled, MallocStackLoggin, and

Another take on the “keyboard obscures UITextField” problem

为君一笑 提交于 2019-12-01 04:19:31
问题 I know that this is a common problem and the UITableViewController fixed this is iPhone SDK 3.0, but the UITableViewController is not working as I expect, probably due to how I am using it. Here's my problem: I'm working on a form, which is in a grouped table, which contains some text fields. Those on the lower part of the form get obscured by the keyboard. I know this is an age-old problem, and there are some examples of code to auto scroll, but I've a little bit more to add, and was

All the alert dialog message and textField have been changed to single line. Please checkout the image

对着背影说爱祢 提交于 2019-12-01 03:59:44
Previously all the dialog and textField are working well. But not I do not know how these TextFields are suddenly changed to single line with triple. (Like some Message here...) let alert = UIAlertController(title: "Cancel Booking !!", message: "Are you sure you want to cancel your booking?", preferredStyle: .alert) alert.addAction(UIAlertAction(title: "No", style: .default, handler: nil)) alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: self.cancelMessageDialog)) self.present(alert, animated: true, completion: nil) I had the same problem and solved it after 3 days and

Attempt to delete row containing first responder that refused to resign

丶灬走出姿态 提交于 2019-12-01 03:43:56
问题 I have an iOS 6-based project that implements a UITableView . Each cell in the table view contains a UITextField allowing the user to enter information. If the user clears a text field, or deletes all input from the field, (i.e. [textfield length] == 0 ) when they tap onto another cell (text field) it deletes the previous cell (text field) from the table view, as it's empty - this avoids empty cells accumulating in the table view. This is all done using a method called -textFieldEditingDidEnd

How to display this little white x-circle in a UITextField, so users can delete the text?

流过昼夜 提交于 2019-12-01 03:24:37
问题 Some apps have this nice little white circle with an gray x in there UITextField. How can I add this to an UITextField and delete the text when it is tapped? 回答1: To add a button like this, you can use the clearButtonMode property of an UITextField. The code will be like this: // Show cancel button never textField.clearButtonMode = UITextFieldViewModeNever; // Show cancel button only when you're editing text in textField textField.clearButtonMode = UITextFieldViewModeWhileEditing; // Show the

Position of rightView UITextField

落花浮王杯 提交于 2019-12-01 03:22:53
Is there a way to adjust the position of a rightView on UITextField? I tried setting the frame on the view (set as rightView) but it didn't change anything. I'd like to avoid making two views, one as the rightView and one as the rightView's subview where I change the subview's position, if possible. The right overlay view is placed in the rectangle returned by the rightViewRectForBounds : method of the receiver. So I suggest you subclass UITextField and override this method, something like this: @interface CustomTextField: UITextField @end @implementation CustomTextField // override