uitextfield

swift playground UITextField spawns keyboard that is too big

帅比萌擦擦* 提交于 2019-12-12 07:52:54
问题 Swift in playground on Mac OS. When the user clicks in a UItextfield, a keyboard spawns but it is very large compared to the view and only the first few keys are available. minimal example: import UIKit import PlaygroundSupport class TesterViewController : UIViewController { var testTextField : UITextField! override func loadView() { let view = UIView() view.backgroundColor = .white testTextField = UITextField() testTextField.borderStyle = .roundedRect testTextField.text = "" view.addSubview

Prevent editing of text in UITextField and hide cursor/caret/magnifying glass while using an inputView

放肆的年华 提交于 2019-12-12 07:46:24
问题 How do I prevent the editing of text in a UITextField along with hiding the cursor/caret/magnifying glass, but still present the keyboard, as I am using an inputView with a UIPickerView / UIDatePickerView ? Setting userInteractionEnabled to NO does not work, because it no longer receives any touches and will not present the keyboard. 回答1: Subclass UITextField //Disables caret - (CGRect)caretRectForPosition:(UITextPosition *)position { return CGRectZero; } //Disables magnifying glass -(void

iOS Swift Pass Closure as Property?

大憨熊 提交于 2019-12-12 07:09:33
问题 Let's say I have a custom UIView, lets call it MyCustomView. Inside this view is a UITextField property. Suppose my goal is to be able to create an instance of MyCustomView and add it to some view controller somewhere, and I want that view controller to be able to handle actions taken on that text field. For example, if I hit "return" on the keyboard within the text field, I may want to do some action - let me give an example of what I'm envisioning with some objective-c psuedo code:

Cannot connect to UITextField

喜夏-厌秋 提交于 2019-12-12 05:18:58
问题 I am making a basic currency conversion app in an attempt to learn ios development, but cannot figure out how to listen to UITextField events. this is my code so far: // // ViewController.swift // Currency // import UIKit class ViewController: UIViewController , UIPickerViewDelegate , UIPickerViewDataSource , UITextViewDelegate , UITextFieldDelegate { @IBOutlet var pickerView : UIPickerView! @IBOutlet var inputTextField : UITextField! @IBOutlet weak var outputText: UILabel! // definface

detect where and what changes within textfield

杀马特。学长 韩版系。学妹 提交于 2019-12-12 04:56:52
问题 How can I check what exactly and where a string changed in my textfieldDidChange method? let str1 = "Hello how are you @Marie, nice day uh?" So imagine my user decides to edit the text and link markus instead of marie let str2 = "Hello how are you @ Markus, nice day uh?" I need a method that detect the change of @ Markus in the text field but doesn't change anything else in the string. I am able to detect last word, first word and so one, but its important to also see what changed within the

Content in UITextView is lost when using the back button in my navigation controller

强颜欢笑 提交于 2019-12-12 04:38:12
问题 I have an iOS app using a tabBarController. Each tabs root view is a navigation controller. In one of the tabs I use a button on the navigation bar to push me to UIViewController that contains a UITextView. The problem I am struggling with is that any content added to the UITextView is lost when back button on the navigation bar is pushed. I have found a few similar questions all with drastically different solutions. I am not sure how to proceed from here. To be clear on what I would like to

How to remove dots in UITextfield?

谁说我不能喝 提交于 2019-12-12 04:33:00
问题 In iOS, I am using one text field the length of the text field id too long so it is showing dots at the end of the text field. I need to remove the dots. I have used lineBreakMode also. See the code I'm using. CGSize maximumSize = CGSizeMake(titleListTxtFld.frame.size.width, 1000); //here 1000 for maximum height u can increase this if u want CGSize strSize = [titleListTxtFld.text sizeWithFont:titleListTxtFld.font constrainedToSize:maximumSize lineBreakMode:UILineBreakModeClip]; CGRect

textFieldShouldBeginEditing called, textFieldDidBeginEditing not called

 ̄綄美尐妖づ 提交于 2019-12-12 04:23:23
问题 I have a simple UITableViewController with 6 rows, each with a UITextField . I want to be able to click on each row and have the keyboard apply to each. Everything works, except for some reason I have to click on each row twice to get the responder to make the next UITextField active. I put in UITextFieldDelegate printouts and the order of their actions seems wrong. Each of the TextFields has been tagged 0 - 5. When I select the first, there is no problem, the keyboard comes up, I enter

Change the border color of uitextfield

喜夏-厌秋 提交于 2019-12-12 04:23:13
问题 I added bottom border to UITextField this way: let bottomLine = CALayer() bottomLine.frame = CGRectMake(0.0, self.frame.height, self.frame.width, CGFloat(borderWidth)) bottomLine.backgroundColor = borderColor.CGColor self.borderStyle = UITextBorderStyle.None self.layer.addSublayer(bottomLine) How can I change the border color of this bottom line when UITextField call textFieldDidBeginEditing() and then change back color to default when it calls textFieldDidEndEditing() I'm using a custom

Disable Alert Button when Text Field is Null with Swift 3

空扰寡人 提交于 2019-12-12 04:19:50
问题 I would like to disable the alert button when the text box is null. I put the button in Table View Cell. So, when you click that button, the alert box will pop up. My codes are below. func cellTapped(cell: DeviceListTableCell) { self.showAlertForRow(row: tableView.indexPath(for: cell)!.row) } func showAlertForRow(row: Int) { let alert = UIAlertController( title: "Enter Password !!!!!", message: "", preferredStyle: .alert) alert.addTextField { (textField) in } let okAction = UIAlertAction