uitextfield

keyboard in UIActionSheet does not type anything

大兔子大兔子 提交于 2019-12-03 19:42:20
问题 I'm wondering why my iPhone keyboard opened by a UITextField doesn't type anything except the delete key and the clear button within the text field itself. The text field is embedded in a UIActionSheet with this code sample: // setup UITextField for the UIActionSheet UITextField* textField = [[UITextField alloc] initWithFrame:CGRectMake(8.0, 34.0, 304.0, 30.0)]; NSString* startText = [[self.pathName lastPathComponent] stringByDeletingPathExtension]; textField.borderStyle =

Set UITextField text property in prepareForSegue

核能气质少年 提交于 2019-12-03 17:07:12
问题 I have a textField in my ViewController1. I have a push segue to my ViewController2 which also has a textField. I need to set the textField.text in my ViewController2 to be equal to the text in the textField in my ViewController1. Here's the code I have: - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqual:@"ViewController2"]) { ViewController2 *VCT = [segue destinationViewController]; VCT.title = @"View Controller #2"; VCT.textField.text = self

UITextfield text position not animating while width constraint is animated

送分小仙女□ 提交于 2019-12-03 16:53:28
I have three UITextField aligned in a container used to choose a date. At first only the month textfield is shown in the container and takes the full width, then when the user chose the month, the day textfield appear and they both take half of the container. The text alignement in these textfields is centered. My problem is that when I animate their size, the text doesn't animate and jumps directly to the final position while the width of the textfields animate correctly . Step 1 : The TextField Before Animation Step 2 : The TexField width is animating but the text is already in the final

Add a permanent Character to UITextField

[亡魂溺海] 提交于 2019-12-03 16:53:04
Is there a way to permanently add a letter to a UITextField where the user cannot delete it? I want to add a single character and the user not be able to delete it but they can still add letters after. Cheers, p.s. This is for iOS A UITextField has a delegate method called should change characters in range, this method basically ask, should i add or remove the next character? and from that you can dictate what you would like. Here is some example code. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { BOOL

How to disable keyboard appearing when hitting on a text field , iOS?

ぃ、小莉子 提交于 2019-12-03 16:44:50
问题 I have a text field , and i need when the user presses it to show a custom picker. The picker is shown fine , but the problem is that the keyboard appears on the bottom and i dont want that. This is an iPad project which i am trying to convert from my iphone one. On the iPhone , this works well and the keyboard is always hidden. What could i be missing/forgetting to do here ? EDIT For future reference what actually happened here , was that in fact both times (iphone & ipad) the keyboard was

iOS 如何解决无法将键盘隐藏

怎甘沉沦 提交于 2019-12-03 16:43:17
问题: 在一个父视图上添加了UITableView以及一个UITextView(UITextView为底部,其余为UITableView的布局)。当点击UITextView的时候,响应正常。当结束写入的时候,需要调用[UITextView resignFirstResponder]来隐藏键盘。这就导致,无法收起键盘。 原因: 当点击UITableView的时候,所触发非UITextView的时候,也就是触摸的是UITableView。当手指touch的时候,响应链便开始从视图的顶部往下响应。当它到达UITableView的时候,UItableView是继承UIScrollewView的,所以,这个信号被UITableView所响应,也就是执行了UITableView的touch方法。所以,UITextView就无法响应。 解决办法: 给UITableView做扩展,让其过滤第一次响应: @implementation UITableView (UITouch) - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [[self nextResponder] touchesBegan:touches withEvent:event]; [super touchesEnded:touches

Hide UISearchBar clear text button

无人久伴 提交于 2019-12-03 16:18:15
问题 I would like to know how to hide or not display the UISearchBar cross that appears in the textField fo the UISearchBar I have tried using this filterSearchBar.showsCancelButton = NO; However this is an actual cancel button not the small grey cross, so I would like to know if there is an equivalent for the small grey button that shows in the UISearchBar . 回答1: You need to get the textField of the Search Bar: UITextField *textField = [searchBar valueForKey:@"_searchField"]; textField

UITextField get currently edited word

旧时模样 提交于 2019-12-03 15:35:32
I'm working on an autocompletion component and I have one problem that I would like to solve in some easy way. I want to support edits to autocompleted text, for example: blablabl @usertag blablabl If user goes back and edits @usertag string, I would like to start autocompletion when it's edited. Question is, how to get currently edited word from textfield. I thought about taking cursor position, seperate nsstring to word by " " (space) and count letters from first word to cursor position. Is there any easier way for doing that? Ok I found a way to do it quite easily. Maybe someone will find

iOS Keyboard (inside UIRemoteKeyboardWindow) is Not Shown When UITextField Becomes First Responder in Touch ID Completion Block (iOS 10)

 ̄綄美尐妖づ 提交于 2019-12-03 15:31:34
问题 I've recently discovered a problem in my app that only seems to occur in iOS 10 where the system keyboard does not display when programmatically triggering a text field to become first responder inside of a completion handler -- specifically the completion handler I get back from a Touch ID attempt. The crazy part of this issue is, even though the keyboard is not shown, the area on the iPhone where the keyboard normally would be is still responding to touch inputs as if the user is typing on

Detecting a change to text in UITextfield

大憨熊 提交于 2019-12-03 15:01:37
问题 I would like to be able to detect if some text is changed in a UITextField so that I can then enable a UIButton to save the changes. 回答1: Take advantage of the UITextFieldTextDidChange notification or set a delegate on the text field and watch for textField:shouldChangeCharactersInRange:replacementString . If you want to watch for changes with a notification, you'll need something like this in your code to register for the notification : [[NSNotificationCenter defaultCenter] addObserver:self