uitextfield

Saving contents of UITextFiled to NSUserDefaults

有些话、适合烂在心里 提交于 2019-12-12 04:18:41
问题 I'm trying to save a textfield and then retrieve it back in the view did load area here is my code: @IBAction func player1button(sender: AnyObject) { NSUserDefaults.standardUserDefaults().setValue(textfield1.text!, forKey:"firstPlayer") } override func viewDidLoad() { super.viewDidLoad() textfield1.text = (NSUserDefaults.standardUserDefaults().valueForKey("firstPlayer") as! String) } I'm getting this error: terminating with uncaught exception of type NSException 回答1: Use stringForKey when

Wierd issues when performing selector “selectAll” on UITextField

房东的猫 提交于 2019-12-12 04:10:15
问题 I am facing the the wierdest bug (ether in my app or in IOS 7.1) ever. After many hours I managed to create a simple app that demonstrate the problem. Two UITextField - Dragged and dropped from interface builder and wired to t1, t2. the ViewController: @implementation ViewController @synthesize t1; @synthesize t2; #pragma mark - UITextFieldDelegate -(void)textFieldDidBeginEditing:(UITextField *)iTextField { NSLog(@"textFieldDidBeginEditing"); [iTextField performSelector:@selector(selectAll:)

UIAlertController: textfield not returning string

久未见 提交于 2019-12-12 03:55:34
问题 There is something unexpected I cannot sort out. I have an alertController with textfields . I try to get the string value of one of them. Everything works fine when the string length is less than 11 characters. Above this threshold, the string is null . Could anyone give me a hint on what there is going on? Just in case, I put my code below: [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.placeholder = @"Name"; textField.textColor = [UIColor

Add UIView when keyboard is shown without being dimmed out

流过昼夜 提交于 2019-12-12 03:47:57
问题 This question is a bit difficult to explain. I have a textfield on top (where the navigation bar is usually is) and when I start editing text, the keyboard shows and auto dims the background. I want to add another UIView below the textfield but have that visible and not dimmed out. Perfect image that describes what I want is this: http://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/Art/keyboard_size.jpg I want to implement something similar like

'Search' label text with UITextField

巧了我就是萌 提交于 2019-12-12 03:43:30
问题 I've got a UILabel and a UITextField. Each time the user enters text in the field, I need to check weather the textfield text exists in the label's text (basically I'm searching the label's text) . I was using NSRange range = [sentenceRequestLabel.text rangeOfString:resultString]; if (range.location == NSNotFound) { NSLog(@"string was found"); } else { NSLog(@"string was not found"); } to check (resultString being the textfield.text), but even if the label text in the text field is not even

UITableView doesn't shift when moving from textField to textField directly

帅比萌擦擦* 提交于 2019-12-12 03:27:58
问题 I'm currently battling with the keyboard covering some textField issue on my Swift based iPhone app. This image shows the primary problem (top three images show the problem, bottom three are what it should be doing): When the textField in the tableViewCell is edited I want to move the whole tableview and navigation bar up. I can do this with the code below (snippets taken from the viewController): var tableViewShiftedUp = false ... func tableView(tableView: UITableView, cellForRowAtIndexPath

UIView automatically moving by uitextfield keyboard

北战南征 提交于 2019-12-12 03:25:16
问题 So i have a really weird problem at my hands and hours of search has provided nothing. I have a uiview containing a uitextfield. Now initially this view is outside of the visible screen with coordinates like x=-500,y=-500. However in response to a button press this view animates and moves into the center of the screen. Now whenever i tap on a uitextfield that is the subview of this view.This view moves back to its original coordinates outside the screen. I have frantically checked my code and

How do I get TextField like this

一世执手 提交于 2019-12-12 03:17:27
问题 I've checked properties of UITextField and tried out to get a design for it like below. But I didn't succeed. I thought to add one more UIView to get that black dim color which is around it. But I didn't know whether any properties are there in UITextField . What do I need to do to get the same design as above. UPDATE : This is my code self.txtUserName = [[UITextField alloc]initWithFrame:CGRectMake(Padding, height/3.5, width - (Padding*2), TextFieldHeight)]; self.txtUserName.backgroundColor =

How to check the textFiled input string when user inputting

送分小仙女□ 提交于 2019-12-12 03:15:12
问题 I have a problem. I have four textfields, but I don't know how to check the textfield that input String. nameField doesn't over 10 strings ageField check whether is number or not sexField check male or female This is my code: - (IBAction)addComment:(id)sender { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Commend" message:nil preferredStyle:UIAlertControllerStyleAlert]; [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {

textFieldShouldReturn: is not called but textFieldDidEndEditing: gets called?

[亡魂溺海] 提交于 2019-12-12 03:07:00
问题 I have a textfield in a UIAlertController and I am trying to implement the delegate method textFieldShouldReturn: which doesn't get called. But i tried implementing the method textFieldDidEndEditing: which gets called without any problem. Please help me here. This is how i do it, __weak typeof(self) weakSelf = self; [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.placeholder = @"Product upc"; textField.textAlignment = NSTextAlignmentCenter;