uitextfield

How to add multiple UITextfield in iOS 5?

社会主义新天地 提交于 2019-12-25 19:37:00
问题 How do I create and add multiple UITextField to my controller? I can create one, like this: UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(5,5,100,25)]; tf.borderStyle = UITextBorderStyleRoundedRect; [tf setReturnKeyType:UIReturnKeyDefault]; [tf setEnablesReturnKeyAutomatically:YES]; [tf setDelegate:self]; [self.view addSubview:tf] But do I need to do that for each UITextField? Whats the best approach to template UI Controls? 回答1: Put it in a loop, offset each text field's Y

Extra whitespace that causes a newline by UITextView at end is ignored

拜拜、爱过 提交于 2019-12-25 17:19:50
问题 This is my code: import UIKit class ViewController: UIViewController { init() { super.init(nibName: nil, bundle: nil) let textView = UITextView(frame: .zero) textView.isScrollEnabled = false textView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(textView) NSLayoutConstraint.activate([ textView.widthAnchor.constraint(equalToConstant: 150), textView.centerXAnchor.constraint(equalTo: view.centerXAnchor), textView.centerYAnchor.constraint(equalTo: view.centerYAnchor) ]) // As

How to make data I enter in a UITextField inside a UIAlertController persist through resets in Swift?

喜欢而已 提交于 2019-12-25 16:51:26
问题 I have been trying to integrate a Pinboard bookmarks view (by parsing an RSS Feed and displaying it in a TableView) in my browser app. To get the username and API Token for the feed I have a UIAlertController in the Settings view of my app. The details entered are preserved through the session but if I force quit the app from the multitasking view, The details are deleted. How can I make them stay? This is the code I'm using for the UIAlertController: @IBAction func

Check live if UITextField is not empty

徘徊边缘 提交于 2019-12-25 16:44:39
问题 I have a UIAlertView which includes an UITextField. The alert view has tow buttons. One normal "dismiss" button and another "add". The "add" button should just be clickable if the UITextField is not empty. I don't know how to check in "real time" if the field is empty. I only saw the possibility to check the textField if the button has been clicked. But that's not what want ("add" button should be grayed out if thextField is empty). Do you have a solution for this? Thanks for your effort! I'm

It is possible to continuously update the UILabel text as user enter value in UITextField in iOS

夙愿已清 提交于 2019-12-25 13:29:56
问题 In my application i have one UILabel and UITextField . Initially UILabel text in nil. As soon as user enter some text in UITextField my UILabel text also Update. Let say When user enter A in UITextField my UILabel immediately show A, B in UITextField my UILabel show B and so on. To achieve this behaviour i used the shouldChangeCharactersInRange function of UITextFieldDelegate . But it always behind one character. say UITextField text = qwerty my UIlabel text show qwert Please help me so i can

How NOT to create a new textfield if one textfield has been added to the cell

可紊 提交于 2019-12-25 11:50:52
问题 I'm using the following code to create the textfield in a UITableView Cell: static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; cell.showsReorderControl = YES; } if (indexPath.row == 1) { UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(15,10,260,40)]; textField

Adding subviews to UITextField leftView property

拥有回忆 提交于 2019-12-25 11:14:15
问题 I am trying to implement an autocomplete text field for the iPhone/iPad. I have subclassed a UITextField. As a user enters search criteria, if the search string matches some entity in our database, then that entity becomes part of the user's search criteria and I want to append a button representing that entity to the leftView property of the text field. That way as the user enters more search criteria, items are appended to the left view, in a similar way to the mail composer when entering

UITextField - Can't unwrap Optional.None

天大地大妈咪最大 提交于 2019-12-25 07:34:59
问题 I just started coding with Swift and I try to build a calculator. When I launch the simulator and I click the button '1' of the calculator it calls Tap0 function. I encountered the following issue: Can't unwrap Optional.None. import UIKit class ViewController: UIViewController { @IBOutlet var display:UITextField override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } @IBAction func Tap0(sender:AnyObject){AddNumber("0")}

shouldChangeCharactersInRange method not work in objective c

筅森魡賤 提交于 2019-12-25 06:48:37
问题 My method is below, it wrong works, when I write the 22222222222 to TCKimlik text field, it must be write the AdText.text = @"AYŞE"; But this method write AYŞE to TCKimlikText.And the AdText textfield shows empty. How can I solve? - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ if ([[TCKimlikText.text stringByReplacingCharactersInRange:range withString:string] isEqual:@"22222222222"]) { cinsiyetBtn.titleLabel.text =

Unable to add text from UITextField to an Array

喜你入骨 提交于 2019-12-25 06:34:27
问题 Currently I have a custom view table cell and a text field just above it. I want to get the text from the UItextfield and put that into an NSMutableArray . Pseudocode: String text = _textfield.text; [array addObject:text]; NSLog{array} In my header file I have created the textfield and the array. I currently receive the error : 'CustomTableView:[340:11303] array: (null)' when I NSLog. I am not to sure why the text from the textfield is not getting added to the array. If any one is able to