FAQ Database Discussion Community


How to switch keyboard between number+punctuation input view and letter input view with code?

objective-c,uitextfield
Is it possible to switch between number input view and letters input view of UIKeyboardTypeASCIICapable with code? I want to show the number input view by default but allow user to input character as well. I need

Swift how to assign a string to a UITextField?

swift,uitextfield
@IBOutlet weak var resultProcessed: UITextField! var str:String = "Mike is here" resultProcessed = str gives error: Cannot assign a value of type 'String' to a value of type 'UITestField!'...

swift - Initialising a float property to the UITextField input

xcode,swift,properties,uitextfield
I am trying to initialise a property of type float from the textfield that user keys in, in the UITextField. I get an error of UITextField is not convertible to 'float' for the below code. Code of type float variable and textfield var forceVar : Float = 0.0 @IBOutlet weak...

swift not updating textfield.text using UIDatePicker

ios,swift,uitextfield,uidatepicker
In swift, I have a textField programmatically declared. override func viewDidLoad() { super.viewDidLoad() textField3.delegate = self textField3.returnKeyType = UIReturnKeyType.Next; datePicker.datePickerMode = UIDatePickerMode.Date datePicker.addTarget(self, action: Selector("handleDatePicker:"), forControlEvents: UIControlEvents.ValueChanged) textField3.inputView = datePicker } func handleDatePicker(sender: UIDatePicker) { textField3.text = dateFormatter.stringFromDate(sender.date) } All the other questions I've found similar to this deal...

Why is my Code Block Instance Variable not Initializing and printing out a “NSGlobalBlock”?

ios,objective-c,uitextfield,spritebuilder
I am using sprite builder and Xcode. Does anyone see where I am going wrong with my code block "whereToNext" property? Im trying to use it to navigate between scenes but for some reason it isn't going into the initialization code in -(void)patterns even though it is going into the...

How do I create a Textfield for Tag-Like-Text Input in iOS?

ios,cocoa-touch,uitextfield
I'm creating a app where the User can input text (words or short phrases) by pressing several buttons. The text gets inserted into a UITextField, where the user can input additional text of his own. To simplify interaction with the already inserted text, I'd love to have a behavior that...

Setting UITextField max length to match screen width?

ios,uitextfield
Hey all I am stumped on this one. I was wondering if there is a way to set the max length of a UITextField to match the width of the screen?

Weird behavior when reloading cells containing textFields in dynamic tableView

ios,objective-c,uitableview,uitextfield
I have a dynamic tableView with custom cells that each contain a textField and label. I want the following behavior: A user taps the "Add" button, and the table inserts a cell at index 0, with the cell's textField becoming the first responder. When the user finishes inputting data, the...

How to check text field empty or not with tags xcode

objective-c,xcode,tags,uitextfield,is-empty
I am using text fields for signup it's have 7 text fields like Name, Email ID, Phone number etc., How do I check each and every text field not empty. I am set tags each text field start from 101 to 108 Is anyway to check that with for loop...

UITextField subclass - subscribing to events

ios,swift,uitextfield,nsnotification
I've created a subclass of UITextField which has its own visual style and functionality. The functionality is to restrict the user to decimal currency values (for example, 3.50), but that's not really relevant because I know the algorithm I have works. The issue is that I want to contain that...

How to insert a Cursor into UILable's Text

swift,ios8,cursor,uitextfield,uilabel
i need to insert a cursor in the text .. i don't want a textField (user don't type in it) .. i just need the cursor itself . so i can put it manually wherever i want .. like button's title . or UILabel .. I tried to just type...

UITextField troubles centering placeholder and changing the keyboard color writing

ios,objective-c,uitableview,uitextfield
i'm actually working into a registration form into my iOs application. I'm still quite new with iOs but I managed to make a good looking registration form thanks to uiTableViewCell customisation and uiTextField. I'm facing 2 problems right now that I fail at solving actually: 1) When I align my...

Accessing UIBarButtonItem textfield.text using swift

ios,swift,uitextfield,uibarbuttonitem
I have a textfield in a toolbar on the bottom of my view that will be used for posting comments. @IBOutlet var commentText: UIBarButtonItem! @IBAction func commentButton(sender: AnyObject) { println(commentText.text) // dosent work } I am trying to get the textfield.text but I can't just say commentText.text because it is...

How do I implement my own data source with HTAutocompleteTextField?

ios,objective-c,uitextfield
On gitub, they have a class called HTAutoCompleteTextField that generates auto fill for UITextFields. My question is, how do I add my own data source to it? The correct method, is obviously - (NSString *)textField:(HTAutocompleteTextField *)textField completionForPrefix:(NSString *)prefix ignoreCase:(BOOL)ignoreCase But, if I have an array of strings, how can I...

how to enable UITextField userinteraction property inside UITableView Cell

ios,objective-c,uitableview,uitextfield
I have UITableViewCell and inside that I have UITextfield, I made 7 sections (dynamic) and each section have one cell (one row) which includes UITextField . Now I have one button on right top corner of UINavigationBar (EDIT button). I need to enable user interaction enable for all section textfields...

how to stop text overlapping in textfield

ios,swift,uitextfield
I have created an image for textfield in my iOS app. But the text seems to overlap the image. Is there any way to prevent this or achieve the same design in another way. Below is the image of the problem I'm facing. Is there any way to make the...

Two separate text fields using a DatePicker instead of keyboard in IOS

ios,swift,datepicker,uitextfield
I have two separate text fields that both use a date picker to select a date, however, when I edit one, both display the same date. How do I separate the two so that each has its own date picker? @IBOutlet weak var dateField1: UITextField! @IBOutlet weak var dateField2: UITextField!...

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

ios,swift,uitextfield,uialertcontroller
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...

Automatically Adjust UIView's Height to It's Subview using AutoLayout (Storyboard)

ios,xcode,uiview,uitextfield,autolayout
I am using StoryBoards and Autolayout. Below is the hierarchy: - Superview -- UIView (ContentView) --- UITextField --- UITextField --- UITextField --- UITextField The UIView(ContentView)'s is constrained to Left, Top, Right of the SuperView with the offset of 20; The Bottom of UIView(ContentView) is not constrained to anything. I would...

Best way to count length of UITextInput text value in Swift?

swift,uitextfield
I have two UITextInput controls that I want to count the number of characters in. For context, I have two inputs: one for email address and one for password. I also have a “Login” button. The button is inactive by default, but as soon as at least one character is...

Dismiss a UIKeyboardTypeNumberPad in a UITextField when VoiceOver is active?

ios,uitextfield,voiceover,uikeyboardtype
How do I dismiss a UITextField with keyboard type UIKeyboardTypeNumberPad? The accepted answer to this question suggests to either add a bar with a dismiss button as an inputAccessoryView or to listen to touch events on the background. I prefer the second approach, i.e. listen to touch events on the...

UIImage at end of UITextView

objective-c,xcode,uiimageview,uitextfield
I have an UITextField, at the end of the textfield I want to add an UIImage. When I put an UIImageView on top of the UITextField, the UIImageView is always (duh!) visible in top of the UITextField. What code do I need to write so that at the end of...

Correct way to replace a default gesture recognizer in Swift

ios,xcode,swift,uitextfield,uigesturerecognizer
I'm trying to disable the default long-press gesture recognizer in a UITextField so that I can add my own long-press gesture recognizer. My code for doing this looks like this: for recognizer:UIGestureRecognizer in textField.gestureRecognizers as! [UIGestureRecognizer] { if recognizer is UILongPressGestureRecognizer{ recognizer = myCustomRecognizer } } But this gives me...

Swift - Default behavior for UITextFields

ios,swift,uitextfield
I've an extension of UITextField that want to change the style when is active / inactive / invalid. I wanted to make all this in a customization in order to avoid code being repeated. It works great when I set this outside the custom textfield (in the view) but throws...

UITextField's numerical pad: dot instead of comma for float values

ios,swift,uitextfield
I'm using a textField which is filled from a numerical pad. Trouble is that, with lot of local region formats (all european, for example), UITextField's numerical pad has comma instead dot, so everytime I write a decimal number, UITextField can't recognise the decimal comma and it round number; for example...

Dismiss keyboard when user taps outside the textField

ios,objective-c,uitextfield
I'm trying to dismiss the keyboard when the user selects something other than the textFiled. I tried the following: - (void)viewDidLoad { mytextField1.delegate = self; mytextFiled2.delegate = self; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.view endEditing:YES]; } This didn't work. I then tried [... resignFirstResponder] in touchesBagan, and that...

Search bar at the top of a UIPickerView in Swift

swift,uitextfield,uisearchbar,uipickerview
So I have a textField, which when the user presses, it shows a UIPickerView, which is populated from an array. Is it possible for there to be search bar at the top of the pickerView, so the user can search for something in the pickerView? I've not seen this done...

How not to append item from UITextField to array if empty or blank spaces - Swift

swift,uitextfield,is-empty,swift-array
This is my very first question on Stack Overflow so I hope I'm following the rules correctly. I'm making a To-Do list app in Swift and I'm trying to prevent blank or empty spaces from being appended to the table. My UITextField: @IBOutlet weak var item: UITextField! My addItem button:...

Problems with keyboard functions?

function,swift,keyboard,uitextfield,ibaction
I am having some trouble with the return key on the keyboard executing code. I have tried in the past and the following code worked perfectly fine: func textFieldShouldReturn(textField: UITextField) -> Bool{ textField.resignFirstResponder() valueOfLetter() return true; } But, for some reason, there is an error on the line valueOfLetter. Here...

uitextfield where arithmetic or pointer type is required.

ios,objective-c,uitextfield,pointer-arithmetic
I have following code and got the error as shown in screen shots. What does this error means - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (textField.tag<10) { if ((textField.text.length >= 1) && (string.length > 0)) { NSInteger nextText = textField.tag + 1; // Try to find next responder UIResponder*...

iOS designable UITextField [closed]

ios,swift,uitextfield,ibdesignable
I was trying to use the IBDesignable within my projects. Could somebody help me to find out how to make work this class? APTextField.swift on gitHub...

UITextField append / between dates while enforcing character limit

ios,objective-c,uitextfield
I am using a UITextField and needing to enforce the following date format: 12/17 I know how to enforce the 4 character limit: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if ([textField isEqual:self.billingExpirationDate]) { if (range.length + range.location > textField.text.length) { return NO; } NSUInteger newLength = [textField.text length] +...

UITextField customization in AppDelegate not working for Swift

ios,swift,uitextfield,appdelegate
I want to customise all the textFields at once via AppDelegate , I had tested the customisation working on individual ViewControllers but when I add the customisation through AppDelegate then it does not appears. Please guide me for what have I missed : func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)...

How to fix UITextView overflow when using autolayout in iOS8?

ios,objective-c,uitableview,uitextfield,autolayout
I am using Autolayout and have a customised UITableViewCell that contains UITextView. The height of the cell and text view should be dynamically resized to accomodate larger contents. Following answers from these links resize ui text view to its content and dynamic ui text view, I have used a height...

How to make UITextField with limitation

ios,iphone,xcode6,uitextfield,uitextfielddelegate
phoneTextField; emailTextField; if i start to type in phoneTextField, emailTextField not allow character . if the phoneTextField length will become 0 means then only emailTextField will allow character. in the same as when start to type in emailTextField, phoneTextField not allow character. if the emailTextFile length will become 0...

UITextField in UIAlertController (border, backgroundColor)

ios,uitextfield,uialertcontroller
Here is a screenshot of a UIAlertController. I was just playing around custom fonts and textfield properties but I was unable to accomplish the following: clear background of the UITextField no ugly border (black box) as shown below As I dived more into the code and iOS runtime headers, I...

How to do a live UITextField count while typing (Swift)?

ios,swift,uitextfield,uitextview
I would like to count the character when user keep typing in UITextField with swift. Image of Field and Label: I have already placed UITextField and UILabel, just haven't found any information on Stack overflow, also if you can do one in UITextView I also appreciate it....

Is it possible to animate UIEdgeInsets?

ios,swift,animation,uitextfield,uiviewanimationtransition
I've been trying to animate a change in UIEdgeInsets. I've already tried using UIView.animateWithDuration and the insets just jump to the final values. Does anyone know if this a property that can't be animated? Or better yet, is anyone aware of a way to animate insets? As an example: //...

How do I add a date of birth UIDatePicker to UITextField?

ios,objective-c,uitextfield,date-of-birth
I request the users date of birth on the sign up screen of my application. I can't figure out how to get a date of birth UIDatePicker to display. I tried using the following code but it only displays the date and time: UIDatePicker *dp = [[UIDatePicker alloc]init]; _textBirthday.inputView =...

Calling UIAlertView on UITextField UIControlEventEditingDidBegin dismisses keyboard

ios,objective-c,uitextfield,uialertview
I've noticed some very weird behavior. I would like to show a UIAlertView when a UITextField is selected: [self.addressTextField addTarget:self action:@selector(addressTextFieldSelected) forControlEvents:UIControlEventEditingDidBegin]; The method that is being called is: - (void)addressTextFieldSelected { if (!geoPoint) { UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Text" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alertView show]; } }...

“Jumping” to the Numbers on a keyboard?

swift,uitextfield,uikeyboard
I have a text field where you usually type in numbers. But, the user has to click the numbers button on the keyboard to get to the numbers screen. Is there a way to jump right to the screen on a keyboard with the numbers are available to type? Any...

How to hide keyboard when you select UIPickerView in Swift

ios,swift,datepicker,uitextfield,uipickerview
I have a DatePicker where the user selects time and date fields, the keyboard shows up first and then I have to click the textfield again for the Picker to appear. What I want is for the DatePicker to show up on the first try. here is my code @IBOutlet...

UITextField Editing Did Begin called on view endEditing

ios,objective-c,uitextfield,uialertview
This all works in my version that's on app store. However if I revert my git to that, it no longer works. It might be since I updated Xcode (now 6.3) but not sure. The issue is: I show a UIAlert when my UITextField 'Editing Did Begin' handler is called....

Swift Gesture recognizers added to textfield inoperable after becomes first responder?

swift,uitextfield,uigesturerecognizer,tap
I added a tap and double tap gesture recognizer to a text field in swift, so that the single tap performs a function but the double tap actually makes the Textfield become first responder. it stops working though after the textfield becomes first responder for the first time. That is,...

UIDatePicker to set UITextfield text

ios,objective-c,uitextfield,uidatepicker
I have a UITextField and a UIDatePicker which I want to use to set the Birthday of the user. I use this code in the viewDidLoad: UIDatePicker *datePicker = [[UIDatePicker alloc] init]; birtdayTextField.inputView = datePicker; However I have 2 problems. I've placed a UIDatePicker in my view in the storyboard....

On click of a UITextField, I want to run some code

ios,swift,uitextfield
I have a UITextField with an outlet called newscore. I am trying to run a block of code when the UITextfield (particularly newscore) is tapped and the keyboard is brought up, or when the user is begin editing the UITextfield. I cant seem to figure out the proper function to...

Is there a way to use UITextField's on a dynamic UITableView, AND 'tab' between them?

objective-c,cocoa-touch,uitextfield,uitextfielddelegate
This may be a tad lengthy, but bear with me. It's mostly simple code and log output. Normally, if I wanted to have a UITextField as a part of a UITableViewCell, I would likely use either a) static rows or b) I would create the cell in the storyboard, outlet...

How do I validate TextFields in an UIAlertController?

ios,swift,uitextfield,uialertview
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:...

Converting fractions into decimals from UITextField in Swift

ios,swift,uitextfield
Is it possible to convert fractions that are entered into UITextField into decimals? So far, this is what I have tried. If I enter in 2/3 into my UITextField, I get 2.0 as my answer. @IBOutlet weak var answer: UITextField! var sAnswer = (answer.text as NSString).doubleValue println(sAnswer) If I just...

Call textFieldDidEndEditing of UITextField when press UIButton

objective-c,uitextfield
Is there anyway to call textFieldDidEndEditing of UITextField when pressed UIButton? Current process is function in textFieldDidEndEditing can work when user press "Return" or "Done" button and click on UIButton. To make it clear, if ABC function in textFieldDidEndEditing to be run, user must press "Return" or "Done" button of...

How to set UITextField text custom position and enter new line?

ios,objective-c,uitextfield
I have a TextField in 350 X 93 size and I have set the control of the TextField to vertical up. But I have an issue that the text become in the top too much which it looks weird. How I can set that text programmatically 10 pixel down? "Comment...

iOS UITextField Outside of SuperView not Responding to Touches

ios,objective-c,uiview,uitextfield,hittest
I'm building an iOS 8 app that makes use of the new hidesBarsOnSwipe property on UINavgitationController to hide the nav bar while scrolling. At the same time that the nav bar hides, I'm also programmatically hiding the tab bar. On top of the tab bar, there is a text field...

Objective c keyboard opens unwillingly

ios,uiview,keyboard,uitextfield,uitextview
I have a "layer builder" object which creates different views and returns them after initialising them. The problem is, whenever i press on one of these created views, the keyboard opens up and i can't understand why. This is how my layer builder is coded: @interface LayerBuilder : NSObject <VENTokenFieldDelegate,...

UITextField placeholder alignment scrolling trouble

ios,objective-c,uitableview,uitextfield,constraints
I'm working on a registration form actually and i'm facing some kind of trouble. I'm using an UITextField into my cell and I wrote a string into the placeholder. Everything runs fine until I try to center the UITextField.textAlignment. It, somehow, manages not to center it. I checked it up...

How to assign textfield or any delegate in Swift Language?

swift,delegates,uitextfield
I am just new born developer for Swift Language. I want to assign textfield delegate to view controller. I tried to assign like this class LoginViewController: UIViewController <UITextFieldDelegate> It's returning following error "Cannot specialize non-generic type 'UIViewController'"...

Check for changes in UITextField

ios,swift,uitextfield
I'm attempting to make an app that checks the text in a UITextField and does something in response to what is written in it. I could possibly have the user type their input and then press a button. I want to be able to check the text field constantly without...

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

ios,objective-c,swift,uitextfield,uilabel
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...

Is it possible to set wide space in UITextField

ios,objective-c,passwords,uitextfield
I have a UITextField which basically take 4 digit NSInteger. Now I want to bring the "Pass code" look into it. What I mean is there will be a certain space between each digit. Something like the below picture. I know I can put space at the font & back...

Swift How to fix do long task in TextField Return key

xcode,swift,uitextfield,uitextfielddelegate
In Swift, I write code to do search list with TextField to users type keyword here, and when the users press ReturnKey, this app do search task, and show result in tableview(bellow TextField). I wrote: func textFieldShouldReturn(textField: UITextField!) -> Bool { var result = ArticleManager.GetListArticleSearch( textField.text , p: 1) if(...

Auto check textfield length and Hit a method UITextfield

ios,objective-c,cocoa-touch,uitextfield
Hello I need to enter mobile number with validation that mobile textfield range should be 10. And when textfield value ==10, i need to call a function when mobile textfield.text length becomes 10. My below code work fine but i need to press 1 more character (means 11) to call...

Adding a UILabel to UIImage with renderInContext

ios,swift,uiimageview,uitextfield,uilabel
I've been trying for a long time to find the best way to add a UILabel with its background color to a UIImage. I need to add a exact replica of the label that is being shown on the screen to the image, if that makes sense to you. The...

Can I press the return key using code?

ios,objective-c,uitextfield
I have a uitextfield and I count the number of characters. The idea is that when the count reaches four then it should go on to the next textfield. The problem is that while the counter tells me that the field does contain four characters the field only shows three...

Dismissing keyboard from textfield inside tableviewcell [duplicate]

ios,objective-c,uitableview,keyboard,uitextfield
This question already has an answer here: How to dismiss keyboard iOS programmatically 11 answers I have a custom tableViewCell which has a textfield inside. How to dismiss keyboard when tap any place outside the textfields? Do I have to look through all cells use [cell.textView resignFirstResponder]?...

Use a text field to set the title of an MKAnnotation in Swift

swift,uitextfield,mkannotation
having registered a long press at a point on the map, I'd like a text field to pop up, so I can set the input as the title of a pin dropped at that point. How would I go about doing this? Heres my code which currently registers a longpress...

tapGestureRecognizer not firing action when on a UIScrollView Swift

ios,swift,uiscrollview,uitextfield
I have a ViewController that has a UIScrollView and the keyboard wont dismiss when using a tapGestureRecognizer. The action wont even fire. Normally this works fine on other ViewControllers that I have built. I think the UIScrollView is eating up all the touch events. I know you can set the...

textFieldDidBeginEditing func is not being called when tapping on a text field

ios,swift,uitextfield
I have a project with three views that are all multiple textFields that call a UIPickerView when tapped. I have two of the views working just fine but when I started on the third one I cannot get the textFieldDidBeginEditing function to be called. I confirmed this by putting a...

Swift: Animating UIButton after auto-formatting UITextField

ios,swift,uibutton,switch-statement,uitextfield
I have a UITextField that only takes numbers. It's a phone number field. Once there are 10 characters in the field (area code + number), I convert the textField.text string to an NSMutableString to format it to a phone number. Now, once the format takes place, I need to animate...

UILineBreakModeCharacterWrap deprecated

ios,objective-c,uitextfield
As I'm trying to solve the code below, the error shown and notifying UILineBreakModeCharacterWrap deprecated in iOS 6. cell.textLabel.lineBreakMode =UILineBreakModeWordWrap; UIFont *font = [UIFont systemFontOfSize:14]; CGSize size =[chatText bound] CGSize size = [chatText sizeWithFont:font constrainedToSize:CGSizeMake(225.0f, 1000.0f)];lineBreakMode:UILineBreakModeCharacterWrap; how do i fix this code? thanks in advance for your contribution....

Add multiple UITextfield in UIAlertview

ios,objective-c,xcode,uitextfield,uialertview
I need to put 5 UITextField in UIAlertView. I use this project: https://www.cocoacontrols.com/controls/aralertcontroller This is my code: ARAlertController *alert = [ARAlertController alertControllerWithTitle:@"My Alert" message:@"This is an alert." preferredStyle:ARAlertControllerStyleAlert]; ARAlertAction* defaultAction = [ARAlertAction actionWithTitle:@"OK" style:ARAlertActionStyleDefault handler:^(ARAlertAction * action) {}]; [alert addAction:defaultAction]; [alert presentInViewController:self animated:YES completion:nil]; Can someone...

coreData existing validation

ios,validation,core-data,uitextfield
so I'm doing application form using CoreData First I'm creating "Shop" with unique name and some properties. In application you can edit that "Shop", and I'm trying to make validation by "shopName" to avoid a creation another "Shop" with same name. I'm using this: -(BOOL)uniqueEntityExistsWithEnityName { BOOL returnValue = NO;...

Validating empty UITextField

ios,uitextfield
i wanted to prompt user if they left out any of the UITextfield in my app. my below code doesn't work, -(IBAction)SignUpclicked:(id)sender{ if ([passwordText.text isEqualToString:0] && [usernameText.text isEqualToString:0] && [AddressText.text isEqualToString:0] && [PhoneText.text isEqualToString:0]){ alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Please Fill all the Field" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil]; } your responses...

Disable editing of a text field

ios,swift,uitextfield
I want to start by saying this is my first project and I am trying hard to find answers myself before posting here. I thought I had found the code to accomplish this. I have no errors but when I run, the field is still editable. So, how can I...

UITextField doesn't work when added via code

ios,swift,uitextfield
I am having a problem with adding UITextField via code. When I use this simple code inside empty view controller all work fine: let textField = UITextField(frame: CGRect(x: 10, y: 10, width: 200, height: 20)) textField.text = "test" scrollView.addSubview(textField) But inside my custom UIScrollView for some reason it won't work...

How to add line at the top of keyboard in ios?

ios,uiview,uitextfield
I have a view in which I show Numeric Keyboard. My problem is that the keyboard is missing a top line. With a white background an unpleasant effect appears: How can I add a 1pt view at the top to simulate top line?...

Unity UI Slider to change UI Text

c,user-interface,unity3d,uitextfield,uislider
Ok Im using unity 4.6 and have a UI slider visible to the player. Beside the slider I have a UI Text which is showing a String of 500. The Slider head is at the right hand side (500) and can be slid left towards what I want to be...

passing textfield data to another view

ios,swift,uitextfield
Am trying to pass the text in the text field to another view here is my code override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { var next:itemDetailsView = segue.destinationViewController as! itemDetailsView if(segue.identifier == "itemV"){ next.titleReceived == titleF.text } } and here how i declared titleF @IBOutlet weak var titleF: UITextField! titleReceived...

how to indent a space between image and text in UITextField

ios,objective-c,cocoa-touch,uitextfield,uikit
I am trying to add a space between the text that user is going to type and an UIImage in a text field . Can any one please help me .

Highlighting some text in a TextField differently

ios,objective-c,iphone,nsstring,uitextfield
I'm creating a recipe by ingredient app. When I type the ingredients on the textfield and then press the find a recipe button it downloads recipes with those typed ingredients but it displays additional ingredients on the label and what I want to do is to display the label with...

How can I disable auto-correct on an input box?

swift,uitextfield,autocorrect
I'd like to disable auto-correct on an input box in my app. I've found a solution for objective-c that looks like this: UITextField* f = [[UITextField alloc] init]; f.autocorrectionType = UITextAutocorrectionTypeNo; I've tried implementing it like this, but it doesn't work: // in my viewController @IBOutlet weak var webAddressInput: UITextField!...

UITextField with partial edit

ios,objective-c,uitextfield,uitextfielddelegate
I want to use a UITextField so that only part of it will be editable. I know about the delegation and shouldChangeCharactersInRange but for some reason, copying the ranged part is allowed. My goal is to get similar result to this (the 'subject' text part) without being able to copy...

Text jumps when animating position of UITextField subclass

ios,objective-c,iphone,animation,uitextfield
When I animate the location of my UITextField subclass, the text in the field jumps out of step with the location of the UITextField holding it, which is very jarring and I can't figure out why it happens: My subclass adds a button to the right hand side of the...

How to send user entered details to email in iOS?

ios,objective-c,xcode,uitextfield
I am storing some user details using POST Request ,my question is whatever details user entered those details should get to my email id. how can i do this ? My code is here : - (IBAction)NextButton:(id)sender { NSLog(@"name:%@",nameTextField.text); NSLog(@"emailid:%@",emailTextField.text); NSLog(@"phonenumber:%@",phoneTextField.text); NSLog(@"pickupaddress:%@",addressTextField.text); if([nameTextField.text isEqualToString:@""] || [emailTextField.text isEqualToString:@""] || [phoneTextField.text isEqualToString:@""]...

Detecting UITextField content changes

ios,swift,uitextfield,uitextfielddelegate
My app keeps crashing when the user types something into a textfield, displaying "NSInvalidArgumentException" and "unrecognized selector sent to instance ...". I am trying to detect when the user does type something, in order to then run some code. I've looked around here on Stackoverflow regarding this, and the code...

How to add text to an active UITextField

swift,uitextfield
I have a couple of UITextField's and one UIButton. If I tap on the UIButton, I want to place some static text in the active UITextField. So something like: @IBAction func buttonEen(sender: UIButton) { 'active textField'.text = "static text" } But how do I determine which UITextField is the active...

How to save text field value in uicollectionviewcell

swift,uitextfield,uicollectionviewcell
hi i have text field in uicollectionviewcell so what i need it example : when i edit text filed value in row 5 and i done it and go to text filed in row 20 to edit value the collectionview has reloaded and forget value in row 5, so i...

Code is not getting called

ios,objective-c,uitextfield,uitextfielddelegate
In the method of shouldChnageTextInRange, I have a block of code validating a textField for currency input. I then tried getting an NSLog from a textField, but I never get results. Here is my edited code I got from this answer: - (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if...

Swift: How to put current URL from UIWebView into UITextField?

swift,url,uiwebview,uitextfield
(XCode 6.3.2, Swift 1.2) I simply want to put the URL of the loaded webpage of the UIWebView into an UITextField. The solutions which I found here doesn't work for me. Here's my code: @IBOutlet weak var addressBar: UITextField! @IBOutlet weak var webView: UIWebView! //some more code... func webViewDidFinishLoad(webView :...

resignFirstResponder vs. endEditing for Keyboard Dismissal

ios,swift,uitextfield
In Swift, both [someTextField].resignFirstResponder() and view.self.endEditing(true) accomplish the same task - hiding the keyboard from the user's view and de-focusing whatever text field was using it. I understand that the former is specific to a particular field, while the latter encompasses the entire view, but other than wanting to target...

Animating uitextfield when user begins editing

ios,objective-c,animation,uitextfield
I have the text field at the bottom of the screen. When the user taps it, the text field should animate up allowing room for the keyboard such as the iOS message app does. Anyway when this occurs, the animation is not happening correctly. Instead of going to where I...

selectedTextRange return nil in UISearchbar iOS

ios,objective-c,uitextfield,uisearchbar,uitextinput
I have aUISearchBar, I get theUITextfield in it and then I want to set selected Text range but it's always return nil. This is my code: UITextField *searchField = [self.searchBar valueForKey:@"_searchField"]; [searchField becomeFirstResponder]; // focus to this searchfield And I fill in the text: self.searchBar.text = @"This is text"; And...

How to put an array in alphabetical order for UIPickerView in Swift

arrays,swift,uitextfield,uipickerview
So I have an array made of strings, and when the user presses on my textfield, it shows a PickerView using the array. I would like the PickerView to show the contents of the array in alphabetical order. But I have no idea how to do this, and cannot find...

Resize UITextField on Edit

ios,objective-c,uitextfield
I have a UITextField in my view which has size constraints to lay out it's position. What I want to happen is for the UITextField to change in width when a user begins to edit the field. I have the view controller set as a delegate for the field and...

UITextField resigning firstResponder too early

ios,objective-c,uitextfield,resignfirstresponder,becomefirstresponder
I have two instances of a UITextField. The returnKeyType of the first text field is UIReturnKeyNext, and the returnKeyType second text field is UIReturnKeyDone. Based of this SO answer, I'm trying resign the first responder of the first text field when the 'Next' button is clicked, and then have the...

wrong Layout for replacing UiNavigationItem.Title with UITextField

ios,objective-c,uitextfield,autolayout,uinavigationitem
i wont replace the UINavigationItem.title with UITextfield. to make this i add in viewDidLoad the TextField UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 150, 30)]; textField.text = @""; textField.placeholder = @"set title here"; textField.font = [UIFont fontWithName:@"Futura-Medium" size:19.0]; textField.textColor = [UIColor whiteColor]; textField.textAlignment = NSTextAlignmentCenter; textField.autoresizingMask = UIViewAutoresizingFlexibleWidth; textField.translatesAutoresizingMaskIntoConstraints = NO;...

UITextField Caret stops moving around when too large

ios,objective-c,uitextfield,user-input,caret
UITextField allows you to override -caretRectForPosition: in subclasses. I want the caret to cover the text field's entire height. - (CGRect)caretRectForPosition:(UITextPosition *)position { CGRect inherited = [super caretRectForPosition:position]; inherited.origin.y = -50.0; inherited.size.height = 200.0; return inherited; } If I make it too large however (like in the example), it will...

iOS 8 Swift : How to keep the keyboard displayed when the UIAlercontroller is presented modally?

ios,swift,keyboard,uitextfield,uialertcontroller
The context is pretty simple, there is a UIViewcontroller with a textfield to enter a phone number. The textfield is in editing mode with keyboard. When the number is entered, the user can tap a button which displays an alert controller. As the alert is presented modally it covers the...

UITextfield text inside UITableViewCell disappearing on scroll

ios,objective-c,uitableview,uitextfield
I'm storing data into NSUserDefaults like so from each of my custom UITableView Cells: for (int i = 0; i < additionalClaimants; i++) { NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0]; UITableViewCell *cell = [self.table_view cellForRowAtIndexPath:indexPath]; UITextField* firstNameField = (UITextField *)[cell viewWithTag:1]; UITextField* employeeIDField = (UITextField *)[cell viewWithTag:2]; [defaults setObject:firstNameField.text forKey:[NSString...

Keyboard autocorrection height (with/without the autocorrection)

ios,iphone,uitextfield,uitextview,uikeyboard
I get the keyboard height like this: - (void)keyboardNotification:(NSNotification*)notification { NSDictionary* keyboardInfo = [notification userInfo]; NSValue* keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameEndUserInfoKey]; CGRect keyboardFrameBeginRect = [keyboardFrameBegin CGRectValue]; } Now, I have the keyboard height. But without the autocorrection height: If the UITextAutocorrectionType is YES / NO the keyboard height stay the same....

UIAlertView save textfield.tex

ios,objective-c,uitextfield,uialertview
I want to replay an alertView with textfield until it will be canceled. The text in the textfield should be save in a NSMutableArray. I tried something, but it doesn't work. It will say by myNSMutableArray = ... EXPECTED identifier. What am I doing wrong? @synthesize myNSMutableArray; - (void)viewDidLoad {...

Turn on Shift key when spacebar is pressed in UITextField

ios,swift,uitextfield
How do I programmatically turn on the shift key (so that the next character is uppercase) on the keyboard when the user presses the spacebar for a UITextField? In addition, I do not want any spaces in the text field such that the user is able to type an entry...