uitextfield

iPhone restrict user from entering space in textfield

为君一笑 提交于 2019-11-30 04:47:47
问题 i want to restrict user from entering space in a UITextField. for this i m using this code - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if ( string == @" " ){ UIAlertView *error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"You have entered wrong input" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; [error show]; return NO; } else { return YES; } } but it is not working .... what is

How can I show the numeric keyboard by default on iPhone?

安稳与你 提交于 2019-11-30 04:39:13
I'm trying the following with no luck. When the user click on a UiTextfield I need to change the keyboard view to the numeric view automatically, is this possible? Jacob Relkin The UITextInputTraits protocol (which UITextField conforms to) has a keyboardType property of type UIKeyboardType . myTextField.keyboardType = UIKeyboardTypeNumberPad; Luda This could be done in the Interface Builder as well: UITextField conforms to UITextInputTraits protocol which means it has keyboardType property which you can set. myField.keyboardType = UIKeyboardTypeNumberPad; You can also set it via interface

what is the difference if i return “YES” or “NO” when i call textFieldShouldReturn

江枫思渺然 提交于 2019-11-30 04:16:33
This is the text field delegate method but i have doubt about return type -(BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return NO; } and this is the same method with different return type -(BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; } by both we can hide key board in i phone . but what is the meaning of return type "YES" or "NO". I am not seeing any difference. The textFieldShouldReturn is a place where you can handle the Return button on the keyboard. textFieldShouldReturn asks the delegate if

resignFirstResponder for all textfields [duplicate]

不想你离开。 提交于 2019-11-30 04:11:36
This question already has an answer here: How do I dismiss the iOS keyboard? 16 answers hiding keyboard ios [duplicate] 4 answers I'm working on an iphone app with multiple textfields on a viewcontroller . I'm a bit confused with resignfirstresponder and setting textfield delegates .I've been able to resign text fields when I set the delegate for one then call resignfirstresponder for that particular textfield. I have a view controller with about 7 text fields and don't want to call each individually. Does anyone have any example code that will close all of the textfields on a view controller

UITextField changes font while editing

感情迁移 提交于 2019-11-30 04:06:16
问题 I am suffering the same problem as here UITextField's custom font changes while in edit mode and could really do with a solution. I have 4 UITextFields that I assign custom fonts in ViewDidLoad. This works and they look great, however when clicking a field to edit the text the font changes back to default text and when resignedfirstresponder the custom font comes back. - (void)viewDidLoad { [super viewDidLoad]; { UIFont *twoDumb = [UIFont fontWithName:@"Dumb" size:20.f]; lbl1.font = twoDumb;

IOS-textfield textview

旧城冷巷雨未停 提交于 2019-11-30 03:50:54
原文链接:https://blog.csdn.net/weixin_36709064/article/details/89256779 1、介绍 UITextView显示多行文本视图,接受编辑输入,类似于文本编辑器,获取焦点的时候会从底部弹出软键盘输入 UITextField类似输入框,比如可用作search输入框,接受文本输入,获取焦点的时候会从底部弹出软键盘输入 2 Delegate Delegate委托协议,有点类似于对接口类的实现,比如Android中Activity实现View.OnClickListener,当有Class实现了View.OnClickListener,那么就需要实现其接口方法onClick(View v),这里Delegate中也会存在相应的回调函数,比如UITextViewDelegate和UITextFieldDelegate各字都有自己可回调的函数。这是通过协议的方式给视图添加回调是IOS的特色。 3 UITextView 和 UITextViewDelegate 要给UITextView添加响应事件可以通过UITextViewDelegate协议来进行,那么怎样将UITextView的响应事件同UITextViewDelegate的回调函数相关连起来呢?注意如果不关联是无法回调到对应的函数的。 3.1 Interface Builder实现

How to change the color of the iOS autocorrect suggestion?

风格不统一 提交于 2019-11-30 03:49:07
问题 After much searching here and on the web and in developer forums, I can't believe that nobody seems to have even asked this question before. The iOS autocorrect suggestions always popup with a blue font on a white background, regardless of the colors of your UITextField or UITextView or anything else. This looks pretty bad sometimes, e.g. on a dark background. It seems bizarre that it would adopt the font of the text you're editing, but have no way to change the default colors. And yet in the

Native UITextField Secure Text Entry forces English (US) keyboard

China☆狼群 提交于 2019-11-30 03:19:29
I have a very simple login page (login + password). My users are french, so their keyboard are French (azerty). Since iOS 12, when they click on the password textfield, which is secured, the keyboard switches to English (qwerty), even if they do not have this keyboard installed on their devices. Moreover, if they do not have this keyboard installed, they can't switch back to their keyboard. I found out that if I deactivate Secure Text Entry, the problem does not show up. I also tried to set isSecureTextEntry programmatically, and the bug shows up. I am adding two screenshots, one for each text

Mixins or Multiple Inheritance in Objective-C?

纵饮孤独 提交于 2019-11-30 03:03:22
问题 Let's say for example that I have MyUITextViewSubclass which inherits from UITextView and MyUITextFieldSubclass which inherits from UITextField and both of those subclasses contain a lot of the same methods and properties to add similar behavior to those UI controls. Since UITextView and UITextField inherit from different classes, is there an easy way to create an abstract class to combine all of that repeated code? In other words, is it possible to create an abstract class that I could

Customize UITextfield of the UISearchbar - iOS

≡放荡痞女 提交于 2019-11-30 02:20:41
I'm trying to customize the textfield for the UISearchbar. The picture below shows my half done work. I have subclasses the UISearchbar and called it from my view controller. I'm trying to remove those dark gray lines from the textfield. Below is the implementation of the UISearchbar adding to subview of the viewcontroller. searchbar = [[SearchBar alloc] initWithFrame:CGRectMake(35,78, 250, 17)]; searchbar.backgroundColor = [UIColor clearColor]; searchbar.layer.borderColor = [[UIColor clearColor] CGColor]; searchbar.layer.borderWidth = 0; for(UIView *view in searchbar.subviews){ if([view