uitextfield

UITextField underlines from NSAttributedString are only 1 pixel high?

旧城冷巷雨未停 提交于 2019-12-04 20:26:11
The label (bottom of the picture) and the text field (top) have the same same attributedText. But look at the underlines. The ones in the text field are only one pixel high. This looks terrible. Does anyone know what is causing this or how to prevent it? - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { UITextField* textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 600, 200)]; NSMutableAttributedString* string = [[NSMutableAttributedString alloc]initWithString:@"The quick brown fox jumps"]; NSNumber* underlineNumber = [NSNumber

Keyboard blocking UITableViewCell's UITextField?

雨燕双飞 提交于 2019-12-04 18:48:29
Currently I have a UITextField in each UITableViewCell but the issue is, if there are 2 cells or more the cell could be cut off. Is there any easy way to make it so that the cell is visible while my keyboard is open? Thanks! MGA If i'm understanding your question correctly, you want the view to scroll when the keyboard shows up. If you make your viewController a subclass of UITableViewController, I believe you get scrolling for free. The only other option is unfortunately not that simple. You need to play around with the delegation methods to move your view up and down (and animate it if you

iPhone string comparison strange issue in iOS 6

守給你的承諾、 提交于 2019-12-04 18:42:52
I used to compare the text entered in a txt field as below, if ([myTextfield.text isEqualToString: @""]) { // success code } else { // my code } in iOS 7 this check works perfectly. If nothing entered in to the text field, condition is success. But in iOS 6 if the field is blank, this condition always false and moves to the else block. So i did like, if (myTextfield.text.length == 0) { // success code } else { // my code } This works fine, and I just wanted to know what is wrong in my first method. If myTextfield.text is nil , [myTextfield.text isEqualToString: @""] will fail because messaging

UITextFieldDelegate vs UITextField control events

为君一笑 提交于 2019-12-04 18:38:15
问题 If I want to handle changes to a UITextField, such as the user typing in it; it seems like this can be done either by assigning a delegate to that text field, and then having the delegate implement shouldChangeCharactersInRange, or by adding a target to the textField, and handling the UIControlEventEditingChanged event. Aside from the fact that with the delegate method, you can return NO and therefor stop the user from making the edit, is there any difference between these 2 things? Same

How can I make my table cell UITextField editable when the table has entered 'edit' mode?

耗尽温柔 提交于 2019-12-04 18:14:05
I have a simple table view which is editable. All I need the user to be able to do is edit the text field in the cell when they choose to edit the table. You need to subclass UITableViewCell to make it editable inline. The default implementation just contains UILabels, which are not editable. For example, if you had a UITextField view in your cell, you'd override - (void)setEditing:(BOOL)editing animated:(BOOL)animated and make the text field become the first responder. 来源: https://stackoverflow.com/questions/2554714/how-can-i-make-my-table-cell-uitextfield-editable-when-the-table-has-entered

How to get a Text Field's text in XCode

断了今生、忘了曾经 提交于 2019-12-04 17:44:12
问题 I made a Text Field with interface builder. How can I get its text to use somewhere else? Is there something like: string text = myTextField.Text; If so, how can I name my text field? 回答1: So the first thing you want to do is create a property in the .h file of the view controller files associated with your xib file like so: @property (strong, nonatomic) IBOutlet UILabel *aLabel; Next in the .m file you need to synthesize it like so: @synthesize aLabel; Within you implementation tag. Now in

remove the border of uitextfield in uisearchbar

回眸只為那壹抹淺笑 提交于 2019-12-04 17:43:40
I wanna custom the UISearchBar control to a style as showed in the picture below: First I should remove the background view, then find out the UITextfiled in UISearchBar, extend the frame of UITextfiled and remove the boarder of it. Here is my code : UITextField *searchField; NSUInteger numViews = [self.subviews count]; for(int i = 0; i != numViews; i++) { if([[self.subviews objectAtIndex:i] isKindOfClass:[UITextField class]]) { //conform? searchField = [self.subviews objectAtIndex:i]; } } if(!(searchField == nil)) { [searchField setBorderStyle:UITextBorderStyleNone]; searchField.frame = self

How do I get the text from UITextField into an NSString?

跟風遠走 提交于 2019-12-04 17:25:43
问题 I've tried various methods, which all give me warnings. Such as userName = [NSString stringWithFormat:@"%@", [yournamefield stringValue]]; which just gives me a warning of 'UITextField' may not respond to '-stringValue' How do i do this? 回答1: Get the text inside the text field using the text property NSString *name = yourNameField.text; 回答2: Use the text property of UITextField : NSString *userName = yourNameField.text; 回答3: How about: userName = [NSString stringWithFormat:@"%@",

iPhone - UITextField with rich text?

心已入冬 提交于 2019-12-04 17:18:42
I want to allow bolding, italic ,underlines ,text-colors, etc in a UITextField. Is there an external library that allows that? or am i suppose to write it myself? Edit: I want the user to be able to edit a portion of the text they way they want, let's say the first word would be bold, the second would be italic, and the third word would be normal Out of the box, you can only format a UITextField in its entirety. There are some libraries that will help you display text using attributed strings but if you need editing capabilities you will have to pretty much write it all from the ground up

textfield backspace action identify when textfield is empty?

回眸只為那壹抹淺笑 提交于 2019-12-04 17:12:00
I am trying to create otp textfield using five textfield.All working fine if you add top, but issue is occurred when user try to add textfield empty and trying to backspace and it was not call any delegate method of UItextfiled which I already added. I tried this :- func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { let char = string.cStringUsingEncoding(NSUTF8StringEncoding)! let isBackSpace = strcmp(char, "\\b") if (isBackSpace == -92) { println("Backspace was pressed") } return true } but it's called when