uitextfield

How do I properly encode Unicode characters in my NSString?

▼魔方 西西 提交于 2019-12-19 10:14:03
问题 Problem Statement I create a number of strings, concatenate them together into CSV format, and then email the string as an attachment. When these strings contain only ASCII characters, the CSV file is built and emailed properly. When I include non-ASCII characters, the result string becomes malformed and the CSV file is not created properly. (The email view shows an attachment, but it is not sent.) For instance, this works: uncle bill's house of pancakes But this doesn't (note the curly

Changing the color of the icons in a UItextField inside a UISearchBar

时光总嘲笑我的痴心妄想 提交于 2019-12-19 09:15:33
问题 I'm trying to customise the appearance of the search bar in my search controller. Setting the background and text colors works fine but I just didn't find a way to change the color of the icons in the text field, specifically the magnifying glass and the x button. I've found this Objective-C code which should do what I want but I'm struggling to translate it to Swift: (EDIT: Skip to the first answer for the working Swift 3 solution.) UITextField *searchBarTextField = [self

Position of rightView UITextField

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-19 05:32:30
问题 Is there a way to adjust the position of a rightView on UITextField? I tried setting the frame on the view (set as rightView) but it didn't change anything. I'd like to avoid making two views, one as the rightView and one as the rightView's subview where I change the subview's position, if possible. 回答1: The right overlay view is placed in the rectangle returned by the rightViewRectForBounds : method of the receiver. So I suggest you subclass UITextField and override this method, something

iOS 11 - disable smart quotes

别来无恙 提交于 2019-12-19 05:11:05
问题 iOS 11 adds smart quotes when typing. In macOS we can disable smart quotes on a NSTextView by setting: textView.automaticQuoteSubstitutionEnabled = NO; Neither UITextField or UITextView seem to have this property or the enabledTextCheckingTypes property. How can smart quotes be disabled on iOS 11? 回答1: Smart quotes and other features such as smart dashes are controlled via the UITextInputTraits Protocol which is adopted by both UITextField and UITextView . Specifically, the smartQuotesType

How to move content of UIViewController upwards as Keypad appears using Swift

孤街醉人 提交于 2019-12-19 05:01:35
问题 I want to move the content of the bottom of my UIViewController upwards as the keypad appears. At the bottom of the view controller I have a UITextField and when the user clicks it the keypad appears and blocks i,t so the user cannot see what they are inputting into the UITextField. I have the UITextField declared as follows: @IBOutlet var startTime : UITextField Would I need a UIScrollView to accomplish this? or is there a way to move the content of the page upwards as the keypad appears.

White line on the bottom on ios 7 with UITextField

萝らか妹 提交于 2019-12-19 04:12:43
问题 I have text field, i need to show the cursor and hide the keyboard. It looks ok in the IOS 6 and IOS 5. But in IOS 7 i can see small white line on the bottom. My code is UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]; [scrollview setDelegate:self]; [self.view addSubview:scrollview]; [self.view bringSubviewToFront:scrollview]; [scrollview setBackgroundColor:[UIColor blackColor]]; scrollview.contentSize = CGSizeMake(768, 1024); UITextField *textField

How to get left padding on UITextField leftView image?

不打扰是莪最后的温柔 提交于 2019-12-19 03:10:59
问题 I am setting up a UIImageView as a leftView on a UITextField like so: UIImageView *envelopeView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.height*.1, self.height*.1)]; envelopeView.image = [UIImage imageNamed:@"envelope.png"]; envelopeView.contentMode = UIViewContentModeScaleAspectFit; envelopeView.bounds = CGRectInset(envelopeView.frame, 15, 10); self.emailAddress.leftView = envelopeView; self.emailAddress.leftViewMode = UITextFieldViewModeAlways; which gets me the following:

UITextField rightView “WhileEditing” problem

扶醉桌前 提交于 2019-12-19 03:01:08
问题 I try to subclass UITextField as follows to implement custom rightView as a Clear button: -(void) drawRect:(CGRect)rect { [self.layer setBackgroundColor:[[UIColor colorWithRed:20.0/255.0 green:20.0/255.0 blue:20.0/255.0 alpha:1] CGColor]]; [self.layer setCornerRadius:15.0]; UIImage *imgClear = [UIImage imageNamed:@"btnClear"]; CGSize iSize = [imgClear size]; UIButton *clearButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, iSize.width, iSize.height)]; [clearButton setImage:imgClear

Storing UITextField contents before view pops

非 Y 不嫁゛ 提交于 2019-12-18 19:33:44
问题 I am sure this is in the Apple documentation or must have been answered somewhere on this forum, since it seems so basic, but I could not find it nor a particularly elegant solution myself. What I have is a UIViewController that pushes an editing view on its navigation stack. The editing view has a bunch of UITextFields in it. If one of them is being editing when the back button is touched, the original view's ViewWillAppear method is called before either the UITextField delegate methods of

Why doesn't dismissWithClickedButtonIndex ever call clickedButtonAtIndex?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 19:02:57
问题 http://iphonedevelopment.blogspot.com/2009/02/alert-view-with-prompt.html I'm using that code to get my iPhone app to display an alertView with an included UITextField and matching CANCEL and OK buttons. The user can enter text, hit CANCEL or OK... and I see the text the user entered... using my code inside the clickedButtonAtIndex method. It all works except for 1 thing: Instead of OK, the user might hit DONE on the keyboard. I'm using dismissWithClickedButtonIndex to simulate an OK click...