概述
ios中對UIResponder對象的定義是一個用于響應(yīng)和處理事件的抽象接口
屬性方法
1宅荤、管理響應(yīng)器
//返回響應(yīng)器鏈中的下一個響應(yīng)器些举,或者如果沒有下一個響應(yīng)器,則為零
@property(nonatomic, readonly, nullable) UIResponder *nextResponder;
//返回接收下一個響應(yīng)者浴讯,如果沒有則為nil
- (nullableUIResponder*)nextResponder;
//是否為第一響應(yīng)者
@property(nonatomic, readonly) BOOL isFirstResponder;
//返回一個布爾值指出接收者是否是第一個響應(yīng)者
- (BOOL)isFirstResponder;
//是否可以成為第一響應(yīng)者静盅,默認(rèn)為NO
@property(nonatomic, readonly) BOOL canBecomeFirstResponder;
//返回一個布爾值指出接收者是否可以成為第一響應(yīng)者,默認(rèn)為NO
- (BOOL)canBecomeFirstResponder;
//請求成為第一響應(yīng)者
- (BOOL)becomeFirstResponder;
//是否愿意放棄第一響應(yīng)者狀態(tài),默認(rèn)為YES
@property(nonatomic, readonly) BOOL canResignFirstResponder;
//返回一個布爾值,指示接收者是否愿意放棄第一響應(yīng)狀態(tài),默認(rèn)為YES
- (BOOL)canResignFirstResponder;
//通知該對象它已被請求在窗口中放棄其作為第一響應(yīng)者的狀態(tài)
- (BOOL)resignFirstResponder;
2予跌、響應(yīng)觸摸事件
//一根手指或多根手指觸摸屏幕
- (void)touchesBegan:(NSSet *)touches withEvent:(nullable UIEvent *)event;
//一根手指或多根手指在屏幕上移動(隨著手指的移動搏色,相關(guān)的對象會持續(xù)發(fā)送該消息)
- (void)touchesMoved:(NSSet *)touches withEvent:(nullable UIEvent *)event;
//一根手指或多根手指離開屏幕
- (void)touchesEnded:(NSSet *)touches withEvent:(nullable UIEvent *)event;
//在觸摸操作正常結(jié)束前,某個系統(tǒng)事件(如有電話打進來)打斷了觸摸過程
- (void)touchesCancelled:(NSSet *)touches withEvent:(nullable UIEvent *)event;
//3D 觸摸事件
- (void)touchesEstimatedPropertiesUpdated:(NSSet *)touches NS_AVAILABLE_IOS(9_1);
3券册、響應(yīng)運動事件
//開始運動
- (void)motionBegan:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
//結(jié)束運動
- (void)motionEnded:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
//取消運動
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
4频轿、響應(yīng)新聞事件
//開始按壓物理按鈕
- (void)pressesBegan:(NSSet *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);
//當(dāng)按壓相關(guān)聯(lián)的值發(fā)生更改時,告知此對象(比如力值變化)
- (void)pressesChanged:(NSSet *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);
//釋放物理按鈕(不在按壓)
- (void)pressesEnded:(NSSet *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);
//當(dāng)系統(tǒng)事件(如低內(nèi)存警告)取消按壓事件時烁焙,告訴這個對象
- (void)pressesCancelled:(NSSet *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);
5略吨、響應(yīng)遠程控制事件
//接收到遠程控制事件時通知對象
- (void)remoteControlReceivedWithEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(4_0);
6、管理輸入視圖
//自定義輸入視圖(一般用于替換UITextField和UITextView對象呈現(xiàn)的系統(tǒng)提供的鍵盤)
@property (nullable, nonatomic, readonly, strong) __kindof UIView *inputView NS_AVAILABLE_IOS(3_2);?
//自定義輸入視圖控制器(一般用于替換UITextField和UITextView對象呈現(xiàn)的系統(tǒng)提供的鍵盤)
@property (nullable, nonatomic, readonly, strong) UIInputViewController *inputViewController NS_AVAILABLE_IOS(8_0);
//自定義輸入附件視圖(一般用于添加到UITextField和UITextView對象呈現(xiàn)的系統(tǒng)提供的鍵盤上)
@property (nullable, nonatomic, readonly, strong) __kindof UIView *inputAccessoryView NS_AVAILABLE_IOS(3_2);
//自定義輸入附件視圖控制器(一般用于添加到UITextField和UITextView對象呈現(xiàn)的系統(tǒng)提供的鍵盤上)
@property (nullable, nonatomic, readonly, strong) UIInputViewController *inputAccessoryViewController NS_AVAILABLE_IOS(8_0);
//當(dāng)對象是第一個響應(yīng)者時考阱,更新自定義輸入和附件視圖
- (void)reloadInputViews NS_AVAILABLE_IOS(3_2);
7翠忠、獲取撤消管理器
@property(nullable, nonatomic,readonly) NSUndoManager *undoManager NS_AVAILABLE_IOS(3_0);
8、驗證命令
//請求接收響應(yīng)器啟用或禁用用戶界面中的指定命令
- (BOOL)canPerformAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(3_0);
//返回響應(yīng)操作的目標(biāo)對象(標(biāo)識與命令相關(guān)聯(lián)的方法的選擇器)
- (nullable id)targetForAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(7_0);
8乞榨、訪問可用的密鑰命令
//響應(yīng)器上觸發(fā)動作的鍵命令
@property (nullable,nonatomic,readonly) NSArray *keyCommands NS_AVAILABLE_IOS(7_0);?
9秽之、管理文本輸入模式
//響應(yīng)器對象的文本輸入模式
@property (nullable, nonatomic, readonly, strong) UITextInputMode *textInputMode NS_AVAILABLE_IOS(7_0);
//響應(yīng)器應(yīng)保存其文本輸入模式信息的標(biāo)識符
@property (nullable, nonatomic, readonly, strong) NSString *textInputContextIdentifier NS_AVAILABLE_IOS(7_0);
//從應(yīng)用程序的用戶默認(rèn)值清除文本輸入模式信息
+ (void)clearTextInputContextIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(7_0);
//在配置鍵盤快捷鍵時使用的輸入助手
@property (nonnull, nonatomic, readonly, strong) UITextInputAssistantItem *inputAssistantItem NS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED __WATCHOS_PROHIBITED;
10当娱、支持用戶活動
//封裝由該響應(yīng)器支持的用戶活動的對象
@property (nullable, nonatomic, strong) NSUserActivity *userActivity NS_AVAILABLE_IOS(8_0);
//恢復(fù)繼續(xù)給定用戶活動所需的狀態(tài)
- (void)restoreUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);
//更新給定用戶活動的狀態(tài)
- (void)updateUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);
11、標(biāo)識符方法
//剪切
- (void)cut:(nullable id)sender NS_AVAILABLE_IOS(3_0);
//拷貝
- (void)copy:(nullable id)sender NS_AVAILABLE_IOS(3_0);
//粘貼
- (void)paste:(nullable id)sender NS_AVAILABLE_IOS(3_0);
//選擇
- (void)select:(nullable id)sender NS_AVAILABLE_IOS(3_0);
//全選
- (void)selectAll:(nullable id)sender NS_AVAILABLE_IOS(3_0);
//刪除
- (void)delete:(nullable id)sender NS_AVAILABLE_IOS(3_2);
//?居左
- (void)makeTextWritingDirectionLeftToRight:(nullable id)sender NS_AVAILABLE_IOS(5_0);
//?居右
- (void)makeTextWritingDirectionRightToLeft:(nullable id)sender NS_AVAILABLE_IOS(5_0);
//切換選定文本的粗體樣式信息
- (void)toggleBoldface:(nullable id)sender NS_AVAILABLE_IOS(6_0);
//切換選定文本的斜體風(fēng)格信息
- (void)toggleItalics:(nullable id)sender NS_AVAILABLE_IOS(6_0);
//切換選定文本的下劃線樣式信息
- (void)toggleUnderline:(nullable id)sender NS_AVAILABLE_IOS(6_0);
//增加選定文本或其他內(nèi)容的大小
- (void)increaseSize:(nullable id)sender NS_AVAILABLE_IOS(7_0);
//減少選定文本或其他內(nèi)容的大小
- (void)decreaseSize:(nullable id)sender NS_AVAILABLE_IOS(7_0);
12考榨、支持的快捷鍵命令(keyCommands是UIResponder類在ios7后新增的一個只讀屬性)
typedef?NS_OPTIONS(NSInteger,UIKeyModifierFlags) {???
?// Alppha+Shift鍵???
UIKeyModifierAlphaShift???? =?1?<<16,?
?//Shift鍵???
UIKeyModifierShift????????? =?1?<<17,?
//Control鍵?
UIKeyModifierControl??????? =?1?<<18, ? ??
?//Alt鍵???
UIKeyModifierAlternate????? =?1?<<19,?
//Command鍵??
UIKeyModifierCommand??????? =?1?<<20, ? ?
//Num鍵
UIKeyModifierNumericPad???? =?1?<<21, ?
}NS_ENUM_AVAILABLE_IOS(7_0);
//初始化對象
- (instancetype)init NS_DESIGNATED_INITIALIZER;
//初始化對象
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
//輸入字符串
@property (nonatomic,readonly) NSString *input;
//按鍵調(diào)節(jié)器
@property (nonatomic,readonly) UIKeyModifierFlags modifierFlags;
//按指定調(diào)節(jié)器鍵輸入字符串并設(shè)置事件
@property (nullable,nonatomic,copy) NSString *discoverabilityTitle NS_AVAILABLE_IOS(9_0);
//創(chuàng)建一個快捷鍵命令
+ (UIKeyCommand *)keyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags action:(SEL)action;
//創(chuàng)建一個快捷鍵命令
+ (UIKeyCommand *)keyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags action:(SEL)action discoverabilityTitle:(NSString *)discoverabilityTitle NS_AVAILABLE_IOS(9_0);?
13跨细、按鍵輸入箭頭指向
//上按鍵
UIKIT_EXTERN NSString *const UIKeyInputUpArrow ? ? ? ? NS_AVAILABLE_IOS(7_0);
//下按鍵
UIKIT_EXTERN NSString *const UIKeyInputDownArrow ? ? ? NS_AVAILABLE_IOS(7_0);
//左按鍵
UIKIT_EXTERN NSString *const UIKeyInputLeftArrow ? ? ? NS_AVAILABLE_IOS(7_0);
//右按鍵
UIKIT_EXTERN NSString *const UIKeyInputRightArrow? ? ? NS_AVAILABLE_IOS(7_0);
//Esc按鍵
UIKIT_EXTERN NSString *const UIKeyInputEscape? ? ? ? ? NS_AVAILABLE_IOS(7_0);