uitextfield

How do I validate TextFields in an UIAlertController?

拈花ヽ惹草 提交于 2019-12-03 08:42:56
问题 Can anyone tell me how to validate UITextFields inside of a UIAlertController ? I need it to prevent the user from clicking "Save" unless both fields are entered. Here is my code so far: @IBAction func btnStart(sender: AnyObject) { var alert = UIAlertController(title: "New user", message: "Add a new user", preferredStyle: .Alert) let saveAction = UIAlertAction(title: "Save", style: .Default) { (action: UIAlertAction!) -> Void in self.textFieldName = alert.textFields![0] as UITextField self

ios - adding text fields to uitableviewcell programmatically not working

回眸只為那壹抹淺笑 提交于 2019-12-03 08:41:35
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 you please tell me what i am missing or is this even the way this is supposed to be done. Your inputs

UiTextView text to separate UITextField's

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can the text in my UITextView be moved to individual UITextFields . For example if i have 5 lines of text in the textview i want that to move to 5 UITextFields allocated for each line. I have at the moment been able to populate a UITableView with the information however it would be easier for what i need to do if it were moved to TextFields instead. 回答1: Try something like: NSArray *subStrings = [myTextView.text componentsSeparatedByString: @"\n"]; textField1.text=subStrings[0]; textField2.text=subStrings[1]; If your textView doens't

UITextField underlines from NSAttributedString are only 1 pixel high?

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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"];

How to select a UITextField?

橙三吉。 提交于 2019-12-03 08:13:28
I want to edit the user's username inside a UITableView. I added a UITextField to the UITableViewCell and this seems to work very nicely. But when the user touches the cell (even outside the textfield), he expects to edit. How do I programatically select the textfield? The code would look something like: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { userName.selected = TRUE; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cellSelected = [tableView cellForRowAtIndexPath: indexPath];

textFieldShouldReturn not being called in iOS

久未见 提交于 2019-12-03 08:12:46
问题 We're trying to figure out how to get the keyboard to hide, but we're having problems getting the textFieldShouldReturn to fire. Why? This is what has been done: *.h @interface MultiSalesViewController : UIViewController <UITextFieldDelegate> *.c txtCardNumber.delegate = self; - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField setUserInteractionEnabled:YES]; [textField resignFirstResponder]; return YES; } Also, the textField has its delegate set to Files Owner in Interface

How can i make a more rounded UITextField? Like the search field in Safari on iPad

混江龙づ霸主 提交于 2019-12-03 07:32:00
HI I'm trying to get a UITextField to look like the google search field available in the safari app on iPad. The purpose of the field will be the same (a search box). I know i could use a UISearchBar but I would have to use hackish code to get rid of the magnifying glass icon and the background and I don't want that. I'm attaching an image with the TextField used by apple as their search box. How can I modify an UITextField to look and behave like the search field in this screenshot? I tried to modified the UITextField's layer roundedCorners property but this doesn't work as expected. Any help

How do I automatically load the keyboard (iOS SDK)?

元气小坏坏 提交于 2019-12-03 06:46:10
问题 really simple question: I got a view that consists of two textfields. When the view loads I want the keyboard to automatically pop up and focus the first field. How do I do that? (In code? In IB?) Thanks a lot! wasabi 回答1: In your viewDidAppear: method call [yourTextField becomeFirstResponder] . 回答2: [myTextField becomeFirstResponder] should do the trick. Also make sure you implement the UITextFieldDelegate methods where you can hide the first responder. 回答3: Well, i know this question has

Multiple pickerviews with multiple textfield inputviews Swift

微笑、不失礼 提交于 2019-12-03 06:39:17
I've been searching through the forum and nothing has helped. I am using 4 text fields in one view controller, and for each textfield, I am using a separate pickerView as the inputViews for the textFields (4pickers). When I click on the first textField, pickerView1 successfully appears and the textfield displays the data, however when I click on the second, third and fourth textfields,the first pickerView appears. I suspect the error lies in the inputView declarations. And I would so appreciate it if you could help add a "done" button to the pickerView. My code: class ViewController1:

Knowing the complete changed string in textField:shouldChangeCharactersInRange:replacementString:

拜拜、爱过 提交于 2019-12-03 06:34:25
问题 I just asked a question about how to monitor changes to a UITextField and received this response : - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)replacementStr { // Enable "Next" if you like what's entered in the replacementStr } This works, but the replacement string is not the whole string, just what it is adding. How can I get the whole string? My objective is to see if the string in the text field is blank or equal to