uitextfield

retrieving integer value from the UITextField into a NSInteger variable

≡放荡痞女 提交于 2019-12-29 09:07:39
问题 UITextField *textField; NSInteger intRollNumber; I want to take rollNumber as input from the textField and store the value into intRollNumber . How i do that? Because I am unable to convert the string into integer. 回答1: Like this? NSString *str = [textField text] int RollNumber = [str intValue]; 回答2: See the text property and integerValue. 来源: https://stackoverflow.com/questions/886925/retrieving-integer-value-from-the-uitextfield-into-a-nsinteger-variable

Struggling with currency in Cocoa

岁酱吖の 提交于 2019-12-29 04:53:30
问题 I'm trying to do something I'd think would be fairly simple: Let a user input a dollar amount, store that amount in an NSNumber (NSDecimalNumber?), then display that amount formatted as currency again at some later time. My trouble is not so much with the setNumberStyle:NSNumberFormatterCurrencyStyle and displaying floats as currency. The trouble is more with how said numberFormatter works with this UITextField. I can find few examples. This thread from November and this one give me some

Compare the text of two text fields

十年热恋 提交于 2019-12-29 01:43:07
问题 How do you compare the text in two text fields to see if they are the same, such as in "Password" and "Confirm Password" text fields? if (passwordField == passwordConfirmField) { //they are equal to each other } else { //they are not equal to each other } 回答1: In Objective-C you should use isEqualToString:, like so: if ([passwordField.text isEqualToString:passwordConfirmField.text]) { //they are equal to each other } else { //they are *not* equal to each other } NSString is a pointer type.

assign copy retain

久未见 提交于 2019-12-28 14:04:42
assign: 简单赋值,不更改索引计数 copy: 建立一个索引计数为1的对象,然后释放旧对象 retain:释放旧的对象,将旧对象的值赋予输入对象,再提高输入对象的索引计数为1 Copy其实是建立了一个相同的对象,而retain不是: 比如一个NSString对象,地址为0×1111,内容为@”STR” Copy到另外一个NSString之 后,地址为0×2222,内容相同,新的对象retain为1, 旧有对象没有变化 retain到另外一个NSString之 后,地址相同(建立一个指针,指针拷贝),内容当然相同,这个对象的retain值+1 也就是说,retain是指针拷贝,copy是内容拷贝。在拷贝之前,都会释放旧的对象。 * 使用assign: 对基础数据类型 (NSInteger)和C数据类型(int, float, double, char,等) * 使用copy: 对NSString * 使用retain: 对其他NSObject和其子类 1.readonly表示这个属性是只读的,就是只生成getter方法,不会生成setter方法. 2.readwrite,设置可供访问级别 3.retain,是说明该属性在赋值的时候,先release之前的值,然后再赋新值给属性,引用再加1。 4.nonatomic,非原子性访问,不加同步,多线程并发访问会提高性能。注意

Change UIFont in secure UITextField strange behaviour in iOS7

你说的曾经没有我的故事 提交于 2019-12-28 11:59:11
问题 I create a simple project: https://github.com/edzio27/textFieldExample.git where I add two UITextField s, one with login and second one with secure password. I've noticed there strange behaviour: click on login and add some text, click on password and add some text, click again to login UITextField Notice that there is a strange behaviour in password font size. It is only appears in iOS7. What can be the problem? Thanks. 回答1: As a couple people pointed out, it appears secure text fields don't

How to detect UIKeyboard “backspace” button touch on UITextField? [duplicate]

假装没事ソ 提交于 2019-12-28 04:01:09
问题 This question already has answers here : Detect backspace in empty UITextField (26 answers) Closed 6 years ago . How can i detect backspace button pressed on UIKeyboard ? thanks EDIT : Is there any keyboard delegate that returns key pressed value? 回答1: if the UITextField is empty, the shouldChangeTextInRange delegate method is not called You can subclass UITextField and override this method: -(void)deleteBackward; { [super deleteBackward]; NSLog(@"BackSpace Detected"); } since UITextField is

How to disable UITextField editing but still accept touch?

≡放荡痞女 提交于 2019-12-28 02:31:05
问题 I'm making a UITextField that has a UIPickerView as inputView . Its all good, except that I can edit by copy, paste, cut and select text, and I don't want it. Only the Picker should modify text field. I've learned that I can disable editing by setting setEnabled or setUserInteractionEnabled to NO . Ok, but the TextField stop responding to touching and the picker don't show up. What can I do to achieve it? 回答1: Using the textfield delegate, there's a method - (BOOL)textField:(UITextField *

Get UITableView to scroll to the selected UITextField and Avoid Being Hidden by Keyboard

笑着哭i 提交于 2019-12-28 01:43:17
问题 I have a UITextField in a table view on a UIViewController (not a UITableViewController ). If the table view is on a UITableViewController , the table will automatically scroll to the textField being edited to prevent it from being hidden by the keyboard. But on a UIViewController it does not. I have tried for a couple of days reading through multiple ways to try to accomplish this and I cannot get it to work. The closest thing that actually scrolls is: -(void) textFieldDidBeginEditing:

Blank space at top of UITextView in iOS 10

邮差的信 提交于 2019-12-27 11:00:39
问题 I have UITextView with some text in it. Everything was fine with iOS 6 but now with iOS 7 it leaves the blank space on top and then place the text below the middle of the textview. I didn't set any contentOffSet. Please Help! 回答1: A text view is a scroll view. View controllers will add a content offset automatically to scroll views, as it is assumed they will want to scroll up behind the nav bar and status bar. To prevent this, set the following property on the view controller containing the

how to 100 text field in table view ios swift [closed]

梦想与她 提交于 2019-12-27 05:36:27
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago . number of cell in table view 100 and every cell having a text field and when ever i am scrolling value should be present in text box . and one another LABEL show no OF index in Table view . 回答1: create data module class as below class Data { var text:String? } then add 100 objects in array and load