uitextfield

UITextField attributedPlaceholder has no effect

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to make the placeholders in my textfields italic, and since my app is targeting iOS 6.0 or newer, decided to use attributedPlaceholder property instead of rolling something more custom. The code goes as follows: NSString *plString = @"optional"; NSAttributedString *placeholder = [[NSAttributedString alloc] initWithString:plString attributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-LightItalic" size:15]}]; for (UITextField *t in myTextfields){ t.placeholder = plString; t.attributedPlaceholder = placeholder; }

iPad UITextField ― cursor not centering when resizing frame with contentVerticalAlignment = UIControlContentVerticalAlignmentCenter

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on a universal iPhone/iPad app. I resize some of my UITextFields as the user types. I also have some code to move the UITextFields around so that their locations make sense as they are resized. This code is not too short, but basically it comes down to modifying the frames of the UITextFields. My UITextFields all have their content vertically centered by setting textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; The text centers just fine. But when I resize the textfield on the iPad, the cursor

UITextField ― observe changes to selectedTextRange?

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there any way to observe changes to the selectedTextRange of a UITextField? I tried observing all UIControlEvents. But changing the selectedTextRange does not trigger a UIControlEvent. Another dead end -- UIKit classes are not KVO compliant. Then there is the UITextFieldTextDidChangeNotification. But that's for changes to the text. Any ideas? 回答1: Subclass UITextField as follows. @interface WJTextField : UITextField @end @protocol WJTextFieldDelegate <UITextFieldDelegate> - (void) textFieldDidChangeSelection: (UITextField *) textField;

iOS UITextField 响应键盘的return 事件

匿名 (未验证) 提交于 2019-12-03 00:39:02
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake( 0 , 0 , 100 , 30 )] textField.returnKeyType = UIReturnKeySearch; // 设置按键类型 textField.enablesReturnKeyAutomatically = YES; // 这里设置为无文字就灰色不可点 在代理方法中响应 - (BOOL)textFieldShouldReturn:(UITextField * )textField { [self searchAction]; [textField resignFirstResponder]; return YES; } 原文:https://www.cnblogs.com/jukaiit/p/9255030.html

Dismissing the First Responder/Keyboard with multiple Textfields

安稳与你 提交于 2019-12-03 00:29:56
Like seriously after going through this... Easy way to dismiss keyboard? ... I have multiple TextFields and a few TextViews . Is there not a way to a have a batch or group Dismiss First Responder for all text fields? Will I need to make method for each field? Maybe I overlooked something in that link? Maybe I can follow something like this: https://stackoverflow.com/questions/3282837/problem-with-multiple-textfields-to-make-the-keyboard-dissapear Would the latter make sense? Thanks in advance. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- I figured it out.... Controller.h @interface

IOS-textfield textview

匿名 (未验证) 提交于 2019-12-03 00:09:02
原文链接: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的特色。 要给UITextView添加响应事件可以通过UITextViewDelegate协议来进行,那么怎样将UITextView的响应事件同UITextViewDelegate的回调函数相关连起来呢?注意如果不关联是无法回调到对应的函数的。 通过在xcode中拖拽。 经过上面操作,弹出的选项对话框delegate选项后面的空心圆圈就变成实心了,如下图

textFieldShouldReturn not being called in iOS

不问归期 提交于 2019-12-02 23:27:04
We're trying to figure out how to get the keyboard to hide, but we're having problems getting the textFieldShouldReturn to fire. Why? This is what has been done: *.h @interface MultiSalesViewController : UIViewController <UITextFieldDelegate> *.c txtCardNumber.delegate = self; - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField setUserInteractionEnabled:YES]; [textField resignFirstResponder]; return YES; } Also, the textField has its delegate set to Files Owner in Interface Builder. One odd thing, is that the viewController's - (void)textFieldDidEndEditing:(UITextField *

UITableViewController not scrolling view when keyboard appears

会有一股神秘感。 提交于 2019-12-02 23:06:23
I have a UITableViewController with around 20 static cells, some of these cells have UITextField s within them and some are just for selecting with a checkmark. The table is about 1.5 views worth so scrolling is required to get at the lower text fields. When I click within a textfield at the bottom of the table the keyboard pops up as it should but this then appears over the cell/textfield. I was under the impression (From Apple docs and elsewhere) that the UITableViewController class handles scrolling of the view automatically when a keyboard appears in any orientation and shifts the

Format currency with UITextField

会有一股神秘感。 提交于 2019-12-02 21:29:44
问题 I have a UITextField that the user will enter an amount of money. I want to set it so it will show the users current currency. I could do the following: - (void)textFieldDidEndEditing:(UITextField *)textField { NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [currencyFormatter setLocale:[NSLocale currentLocale]]; [currencyFormatter setMaximumFractionDigits:2]; [currencyFormatter setMinimumFractionDigits:2]; [currencyFormatter

How do I automatically load the keyboard (iOS SDK)?

怎甘沉沦 提交于 2019-12-02 21:17:38
really simple question: I got a view that consists of two textfields. When the view loads I want the keyboard to automatically pop up and focus the first field. How do I do that? (In code? In IB?) Thanks a lot! wasabi In your viewDidAppear: method call [yourTextField becomeFirstResponder] . Devraj [myTextField becomeFirstResponder] should do the trick. Also make sure you implement the UITextFieldDelegate methods where you can hide the first responder. Well, i know this question has already been answered many times. It takes time to display a keyboard after viewDidAppear method gets called. The