uitextfield

Getting the cursor position of UITextField in ios

ぃ、小莉子 提交于 2019-12-04 16:35:05
问题 I am trying to control the cursor position in the UITextField. Users cannot insert more than one character at a time into the middle of the text field. It moves it to the end of the textfield. So this post in SO: Control cursor position in UITextField It solves my problem. But I need to know the current cursor position. My code looks like this: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (textField.tag ==

Set focus to UITextField in tableCell

Deadly 提交于 2019-12-04 15:31:09
问题 I am creating a table view with UITextField s dynamically. l_textField = [[UITextField alloc] initWithFrame:TextFieldFrame]; l_textField.tag = cellRow; l_textField.delegate = self; l_textField.font = [UIFont boldSystemFontOfSize:14]; l_textField.textColor = [UIColor blackColor]; [l_textField setEnabled:YES]; [cell.contentView addSubview:l_textField]; And now I want to set focus on this text field when user touch cell. I write this - (void)tableView:(UITableView *)tableView

Limiting NSString to numbers as well as # if chars entered. (code included)

走远了吗. 提交于 2019-12-04 15:22:09
I have searched the site for my answer, however I think it is also how I got myself into this problem. I'm trying to limit my 1 and only text field to 10 characters and only numbers. Below is code mostly off other questions on this site. What I am trying to do is mash this code together for my limits - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:LEGAL] invertedSet]; NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]

UISeachBar detect when user press Search button

≯℡__Kan透↙ 提交于 2019-12-04 15:21:04
问题 I try to get notification when the Search button is clicked in the keyboard in the UISearchBar with this : - (BOOL)textFieldShouldReturn:(UITextField *)textField{ return YES; } But this method won't call when I press the Search button. 回答1: Have you tried this delegate Objective-C: - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar Swift: func searchBarSearchButtonClicked(searchBar: UISearchBar) See the documentation for any searchbar delegates. https://developer.apple.com

How to implement newsfeed comment page similar to Facebook or Instagram

痞子三分冷 提交于 2019-12-04 14:57:16
Both Instagram and Facebook allow their users to comment on news feeds. In the comment scene, they basically have a UITableView with all the comments and a “footer” where user may enter comments and post them. So the “footer” is a UIView or UIToolBar with a UITextField/UITextView and a UIButton. Truly simple stuff from the look of it. Well I have been trying to implement it and the keyboard is not cooperating. I need the keyboard to not hide the “footer”. Especially now in iOS 8 the keyboard comes with a suggestions tool bar that a user may choose to show or hide. All these interactions make

ios - adding text fields to uitableviewcell programmatically not working

感情迁移 提交于 2019-12-04 14:49:27
问题 Rookie ios question. I am trying to create a sign up form using a table view controller. I am trying add textfields to each cell programmatically in the cellForRowAtIndexPath method but all my text fields seem to getting created on the first cell - one overlapping the other. Here is my code. Here is how my cells are rendering. I think I am doing something goofy with the part that is reusing the cells. I did check some some other similar threads on stackoverflow but none of them helped. Could

In Swift, how do you detect which UIControlEvents triggered the action?

孤街浪徒 提交于 2019-12-04 14:48:06
I currently have 4 UITextField's @IBOutlet weak var fNameTextField: UITextField! @IBOutlet weak var lNameTextField: UITextField! @IBOutlet weak var emailTextField: UITextField! @IBOutlet weak var phoneTextField: UITextField! and I want to keep track of their various events: [UIControlEvents.EditingChanged, UIControlEvents.EditingDidBegin, UIControlEvents.EditingDidEnd ] but I don't want to have 3 event separate event handlers so I created a single function like this. This function does a great job of telling me which UITextField fired an event but it doesn't tell me which event was triggered.:

iPhone - UITextView should look like a UITextField

萝らか妹 提交于 2019-12-04 14:12:39
I need a textfield so an user could write several lines. Unfortunately a UITextField does not provide several lines, so I think I have to use an UITextView. But the design of both are not the same. Is it possible to design the UITextView like the UITextfield standard with white background and rounded corners? Thanks a lot in advance & Best Regards. In my self appointed role as interface-nazi, I feel compelled to point out that UITextField and UITextView have different appearances to communicate to users to expect a slightly different function. In a textfield, a return ends editing. In a

How to enable or disable the keyboard return key [duplicate]

点点圈 提交于 2019-12-04 13:32:27
This question already has answers here : How to disable/enable the return key in a UITextField? (7 answers) Closed 4 years ago . When we enter character in textfield then it is enabling the return key. But in our requirement we need to enable the return key when length is more than 5. But now as soon as we enter character it is enabling the return key. Do we need to customize the keyboard or is there any other solution available. Thanks in advance. Suhaiyl Well I think you should handle it in the UITextField delegate : - (BOOL) textFieldShouldReturn:(UITextField*) textField { return textField

How to get the TextField position in a TableCell on iPhone?

一个人想着一个人 提交于 2019-12-04 13:23:06
Here is the UI...(I know it is ugly...) The orange is a view, and the blue is the table, and the gray one is the table cell, lastly, the red is a textfield in a table cell. My question is simple, I just wanna to know the red text field position... Seems the table cell may move up and down, so, the position can be changed. So, I don't need to dynamic update the text field position, I just need the position when the user click the text field, any ideas? Thanks. you can make use of convetrPoint methods that can be used on an UIView or its derived classes - (CGPoint)convertPoint:(CGPoint)point