NSNotification在UITextField的应用
来源:互联网 发布:梦洁床垫怎么样知乎 编辑:程序博客网 时间:2024/05/19 13:45
二NSNotificationNS_CLASS_AVAILABLE_IOS(2_0) @interface UITextField : UIControl <UITextInput,NSCoding>
@end
//UITextField的委托
@protocol UITextFieldDelegate <NSObject>
@optional
//委托实现的方法
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField; // return NO to disallow editing.
- (void)textFieldDidBeginEditing:(UITextField *)textField; // became first responder
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField; // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end
- (void)textFieldDidEndEditing:(UITextField *)textField; // may be called if forced even if shouldEndEditing returns NO (e.g. view removed from window) or endEditing:YES called
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; // return NO to not change text
- (BOOL)textFieldShouldClear:(UITextField *)textField; // called when clear button pressed. return NO to ignore (no notifications)
- (BOOL)textFieldShouldReturn:(UITextField *)textField; // called when 'return' key pressed. return NO to ignore.
@end
//UITextField通知
UIKIT_EXTERNNSString *const UITextFieldTextDidBeginEditingNotification;
UIKIT_EXTERNNSString *const UITextFieldTextDidEndEditingNotification;
UIKIT_EXTERN NSString *const UITextFieldTextDidChangeNotification;
三NSNotification在NSTextField中的使用
@interface NSNotification :NSObject <NSCopying,NSCoding>
@end
/**************** Notification Center****************/
@interface NSNotificationCenter :NSObject {
@package
void *__strong _impl;
void *__strong _callback;
void *_pad[11];
}
+ (NSNotificationCenter *)defaultCenter;
- (void)addObserver:(id)observer selector:(SEL)aSelector name:(nullableNSString *)aName object:(nullableid)anObject;
- (void)postNotification:(NSNotification *)notification;
- (void)postNotificationName:(NSString *)aName object:(nullableid)anObject;
- (void)postNotificationName:(NSString *)aName object:(nullableid)anObject userInfo:(nullableNSDictionary *)aUserInfo;
- (void)removeObserver:(id)observer;
- (void)removeObserver:(id)observer name:(nullableNSString *)aName object:(nullableid)anObject;
- (id <NSObject>)addObserverForName:(nullableNSString *)name object:(nullableid)obj queue:(nullableNSOperationQueue *)queue usingBlock:(void (^)(NSNotification *note))blockNS_AVAILABLE(10_6, 4_0);
// The return value is retained by the system, and should be held onto by the caller in
// order to remove the observer with removeObserver: later, to stop observation.
@end
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textFieldTextDidChange) name:UITextFieldTextDidChangeNotification object:password];
[[NSNotificationCenterdefaultCenter]addObserverForName:UITextFieldTextDidBeginEditingNotification
object:nilqueue:nilusingBlock:^(NSNotification *note) {
if (Self == note.object) {
//do something }
}];
- NSNotification在UITextField的应用
- 键盘遮挡的处理。UITextField在实际的应用(综合应用, 有点小难度)
- iOS 监听(NSNotification)的优缺点和项目实践应用
- ios 监听(NSNotification)的使用(在项目中已使用) .
- UILabel,UITextField 以及UIButton的应用
- NSNotification的用法
- NSNotification的使用
- iOS NSNotification的使用
- NSNotification的用法
- NSNotification的使用
- NSNotification的使用
- cocoa的NSNotification通知
- NSNotification的用法
- NSNotification的详细讲述
- iOS NSNotification的使用
- iOS NSNotification的使用
- iOS NSNotification的使用
- NSNotification的用法
- jQuery-Ajax
- 快稳炫:电商峰值系统架构三字诀
- Scala Worksheet
- PHP变量的定义与相应的数据类型
- java关于参数传递的思考
- NSNotification在UITextField的应用
- FragmentManager分析(个人笔记)
- HDU-ACM2074
- 并查集总结
- mysql大页内存的使用
- VMware下 Ubuntu 看不到共享文件夹之解决办法
- 45-Letter Combinations of a Phone Number
- Filezilla client站点出现中文乱码的解决办法
- HDU-ACM2075