uitextfield

How to restrict textfield to accept only decimal values in swift

梦想的初衷 提交于 2020-01-07 04:19:29
问题 I want to accept only decimal values in my textfield. The following code allows me to enter only numbers and '.' but we can enter more than one '.' How can i restrict it to just one '.' or how can I restrict the textfield to accept only decimal values in swift 3.1 let aSet = NSCharacterSet(charactersIn:"0123456789.").inverted let compSepByCharInSet = r_Qty_txt.text?.components(separatedBy: aSet) let numberFiltered = compSepByCharInSet?.joined(separator: "") My target device is iPad.

It's Possible to change default selection color in UITextField iOS?

雨燕双飞 提交于 2020-01-06 21:09:25
问题 Default selection color is blue as - I required to change it clear color? I know If I change tint color then that color will be set when I select ant text but my question When I set clear color as tint color then there should be no color displaying for selection of text but It is taking gray color as default. if It is posiible then How? and please provide source code. This is what happens when tint color is blue if i set tintColor = clear color than display gray color. This happens when tint

Can not pass value of textfield to other viewcontroller in ios

蓝咒 提交于 2020-01-06 20:37:18
问题 I want to pass value of textfield in LoginView to uploadview but UserLogin1 always is NULL ( 0x000000) This is my codes: loginvuew.h @property (nonatomic,retain) IBOutlet UITextField *username; loginview.m -(IBAction)LoginButton:(id)sender{ uploadview= [[UploadTab alloc] initWithFrame:CGRectMake(0,0,0,0) andUsertring:username.text]; } uploadview.h @property (nonatomic, copy) NSString *UserLogin1; - (id)initWithFrame:(CGRect)frame andUsertring:(NSString *)strUser; uploadview.m - (id

Can not pass value of textfield to other viewcontroller in ios

北战南征 提交于 2020-01-06 20:37:03
问题 I want to pass value of textfield in LoginView to uploadview but UserLogin1 always is NULL ( 0x000000) This is my codes: loginvuew.h @property (nonatomic,retain) IBOutlet UITextField *username; loginview.m -(IBAction)LoginButton:(id)sender{ uploadview= [[UploadTab alloc] initWithFrame:CGRectMake(0,0,0,0) andUsertring:username.text]; } uploadview.h @property (nonatomic, copy) NSString *UserLogin1; - (id)initWithFrame:(CGRect)frame andUsertring:(NSString *)strUser; uploadview.m - (id

UITextField strange behavior when delete symbol in first time

微笑、不失礼 提交于 2020-01-06 18:08:37
问题 When I push my ViewController one of the textfield must be have text, I make it and it is all good cell.textFieldMain.text = [NSString stringWithFormat:@"+7 (%@) %@-%@",[num substringToIndex:3], [num substringWithRange:NSMakeRange(3, 3)], [num substringFromIndex:6]]; I have method that put cursor in the needed place, because I make template for textfield My method: - (void)setCurcorForTextField:(UITextField *)textField position:(NSInteger)position { UITextPosition *newPosition = [textField

Swift calculate value of UITextFields and return value

ぐ巨炮叔叔 提交于 2020-01-06 17:59:50
问题 Using swift and Xcode 6, I'm trying to return a value calculated based on content of few UITextFields. I have declared variables var Number1 = Field1.text.toInt() var Number2 = Field2.text.toInt() var Duration = Number1*Number2 Mylabel.text = String ("\(Duration)") The idea is to capture duration from few UI Fields and based on calculation of those values assign that to a variable as well as display it on a label. In line: var Duration = Number1*Number2 Challenge is that I have is that when

UILongPressGestureRecognizer not working on UITextField

与世无争的帅哥 提交于 2020-01-06 08:19:08
问题 I have a LongPress gesture recognizer initialized in the viewDidLoad method of my viewcontroller as below: longPressGesture_= [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(displayTimeFlagCallout)]; I have a tableview in my viewcontroller. The tableview has custom cells. Each cell has 2 textfields. I want to bring up a custom popover when a user long presses on the text fields (startTime and endTime). I do not want the magnifying glass and the Copy/Paste popover to

Adjust View For Keyboard When Switching UITextField?

大兔子大兔子 提交于 2020-01-06 08:09:27
问题 I have the ability for my view to slide up when the keyboard appears in my app so the text field can be seen and it worked just fine. However, because its based on keyboard notifications it only works when the keyboard appears. Meaning, I select a textfield, the keyboard appears and the view slides up accordingly, but if I then tap directly onto another textfield the view doesn't adjust because the keyboard is already present. Here is the code I am using, any help adapting this to work in a

Adjust View For Keyboard When Switching UITextField?

佐手、 提交于 2020-01-06 08:08:16
问题 I have the ability for my view to slide up when the keyboard appears in my app so the text field can be seen and it worked just fine. However, because its based on keyboard notifications it only works when the keyboard appears. Meaning, I select a textfield, the keyboard appears and the view slides up accordingly, but if I then tap directly onto another textfield the view doesn't adjust because the keyboard is already present. Here is the code I am using, any help adapting this to work in a

UITextField move up when keyboard appears in Swift

爱⌒轻易说出口 提交于 2020-01-06 03:48:04
问题 I use this code for move the view up when keyboard appears, in my login page this code worked great, but in the signup page it did not work. func textFieldDidBeginEditing(textField: UITextField) { animateViewMoving(true, moveValue: 100) } func textFieldDidEndEditing(textField: UITextField) { animateViewMoving(false, moveValue: 100) } func animateViewMoving (up:Bool, moveValue :CGFloat){ var movementDuration:NSTimeInterval = 0.3 var movement:CGFloat = ( up ? -moveValue : moveValue) UIView