UIResponder定義

//
// UIResponder.h
// UIKit
//
// Copyright (c) 2005-2016 Apple Inc. All rights reserved.
//

import <Foundation/Foundation.h>

import <UIKit/UIKitDefines.h>

import <UIKit/UIEvent.h>

NS_ASSUME_NONNULL_BEGIN
//引入類
@class UIPress;
@class UIPressesEvent;

@protocol UIResponderStandardEditActions <NSObject>
@optional
//剪切

  • (void)cut:(nullable id)sender NS_AVAILABLE_IOS(3_0);
    //復(fù)制
  • (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);
    //斜體
  • (void)toggleItalics:(nullable id)sender NS_AVAILABLE_IOS(6_0);
    //下劃線
  • (void)toggleUnderline:(nullable id)sender NS_AVAILABLE_IOS(6_0);
    //增加尺寸
  • (void)increaseSize:(nullable id)sender NS_AVAILABLE_IOS(7_0);
    //減少尺寸
  • (void)decreaseSize:(nullable id)sender NS_AVAILABLE_IOS(7_0);

@end

NS_CLASS_AVAILABLE_IOS(2_0) @interface UIResponder : NSObject <UIResponderStandardEditActions>

if UIKIT_DEFINE_AS_PROPERTIES

//下一個(gè)響應(yīng)者屬性
@property(nonatomic, readonly, nullable) UIResponder *nextResponder;

else

//下一個(gè)響應(yīng)者

  • (nullable UIResponder*)nextResponder;

endif

if UIKIT_DEFINE_AS_PROPERTIES

//是否能成為第一響應(yīng)者,默認(rèn)為NO
@property(nonatomic, readonly) BOOL canBecomeFirstResponder; // default is NO

else

//是否能成為第一響應(yīng)者,默認(rèn)為NO //方法

  • (BOOL)canBecomeFirstResponder; // default is NO

endif

//成為第一響應(yīng)者,成功返回Yes.

  • (BOOL)becomeFirstResponder;

if UIKIT_DEFINE_AS_PROPERTIES

//是否可以辭去第一響應(yīng)者,默認(rèn)為YES.
@property(nonatomic, readonly) BOOL canResignFirstResponder; // default is YES

else

//是否可以辭去第一響應(yīng)者,默認(rèn)為YES. //方法

  • (BOOL)canResignFirstResponder; // default is YES

endif

//辭去第一響應(yīng)者,成功返回YES.

  • (BOOL)resignFirstResponder;

if UIKIT_DEFINE_AS_PROPERTIES

//是否是第一響應(yīng)者.
@property(nonatomic, readonly) BOOL isFirstResponder;

else

//是否是第一響應(yīng)者.

  • (BOOL)isFirstResponder;

endif

// Generally, all responders which do custom touch handling should override all four of these methods.
//一般來(lái)說(shuō),所有的響應(yīng)者--做自定義觸摸處理的應(yīng)該重寫一下四個(gè)方法.
// Your responder will receive either touchesEnded:withEvent: or touchesCancelled:withEvent: for each
// touch it is handling (those touches it received in touchesBegan:withEvent:).
//你的響應(yīng)者將會(huì)接收touchesEnded:withEvent: or touchesCancelled:withEvent:
對(duì)于每一個(gè)觸摸.他是處理(those touches it received in touchesBegan:withEvent:).
// *** You must handle cancelled touches to ensure correct behavior in your application. Failure to
//你必須手動(dòng)取消觸摸去確定正確的行為在你的app上.
// do so is very likely to lead to incorrect behavior or crashes.
//失敗去做所有是很可能的導(dǎo)致錯(cuò)誤的行為甚至崩潰.
//觸摸開始

  • (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
    //觸摸移動(dòng)
  • (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
    //觸摸結(jié)束
  • (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
    //觸摸取消
  • (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
    //預(yù)估觸摸.
  • (void)touchesEstimatedPropertiesUpdated:(NSSet<UITouch *> *)touches NS_AVAILABLE_IOS(9_1);

// Generally, all responders which do custom press handling should override all four of these methods.
//一般來(lái)說(shuō),所有的響應(yīng)者--自定義按壓應(yīng)該重寫下面四個(gè)方法.
// Your responder will receive either pressesEnded:withEvent or pressesCancelled:withEvent: for each
// press it is handling (those presses it received in pressesBegan:withEvent:).//同上差不多.
//按壓改變將會(huì)被按壓--模擬值觸發(fā).
// pressesChanged:withEvent: will be invoked for presses that provide an analog value
// (like thumbsticks or analog push buttons).//類似...
// *** You must handle cancelled presses to ensure correct behavior in your application. Failure to
// do so is very likely to lead to incorrect behavior or crashes.//同上差不多.
//按壓開始.

  • (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);
    //按壓改變
  • (void)pressesChanged:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);
    //按壓結(jié)束
  • (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);
    //按壓取消.
  • (void)pressesCancelled:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);
    //手勢(shì)開始
  • (void)motionBegan:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
    //手勢(shì)結(jié)束
  • (void)motionEnded:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
    //手勢(shì)取消.
  • (void)motionCancelled:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
    //遠(yuǎn)程控制接受者.
  • (void)remoteControlReceivedWithEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(4_0);
    //是否可以執(zhí)行給定動(dòng)作.
  • (BOOL)canPerformAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(3_0);
    // Allows an action to be forwarded to another target. By default checks -canPerformAction:withSender: to either return self, or go up the responder chain.
    //允許轉(zhuǎn)移動(dòng)作的執(zhí)行者.
  • (nullable id)targetForAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(7_0);
    //撤回和重做.
    @property(nullable, nonatomic,readonly) NSUndoManager *undoManager NS_AVAILABLE_IOS(3_0);

@end

typedef NS_OPTIONS(NSInteger, UIKeyModifierFlags) {
UIKeyModifierAlphaShift = 1 << 16, // This bit indicates CapsLock
UIKeyModifierShift = 1 << 17,
UIKeyModifierControl = 1 << 18,
UIKeyModifierAlternate = 1 << 19,
UIKeyModifierCommand = 1 << 20,
UIKeyModifierNumericPad = 1 << 21,
} NS_ENUM_AVAILABLE_IOS(7_0);

NS_CLASS_AVAILABLE_IOS(7_0) @interface UIKeyCommand : NSObject <NSCopying, NSSecureCoding>
//初始化

  • (instancetype)init NS_DESIGNATED_INITIALIZER;
    //初始化從解檔
  • (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
    //輸入
    @property (nonatomic,readonly) NSString *input;
    //修改標(biāo)志
    @property (nonatomic,readonly) UIKeyModifierFlags modifierFlags;
    //發(fā)現(xiàn)可用的標(biāo)題
    @property (nullable,nonatomic,copy) NSString *discoverabilityTitle NS_AVAILABLE_IOS(9_0);

// The action for UIKeyCommands should accept a single (id)sender, as do the UIResponderStandardEditActions above
//這個(gè)UIKeyCommands的動(dòng)作應(yīng)該接收一個(gè)單獨(dú)的sender,作為在UIResponderStandardEditActions之上.
// Creates an key command that will not be discoverable in the UI.
//創(chuàng)建一個(gè)key command 將不會(huì)被發(fā)現(xiàn)在ui層次.
//初始化key command .

  • (UIKeyCommand *)keyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags action:(SEL)action;

// Key Commands with a discoverabilityTitle will be discoverable in the UI.
///創(chuàng)建一個(gè)key command 將會(huì)被發(fā)現(xiàn)在ui層次.

  • (UIKeyCommand *)keyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags action:(SEL)action discoverabilityTitle:(NSString *)discoverabilityTitle NS_AVAILABLE_IOS(9_0);

@end

@interface UIResponder (UIResponderKeyCommands)
//命令行
@property (nullable,nonatomic,readonly) NSArray<UIKeyCommand *> *keyCommands NS_AVAILABLE_IOS(7_0); // returns an array of UIKeyCommand objects<
@end

@class UIInputViewController;
@class UITextInputMode;
@class UITextInputAssistantItem;

@interface UIResponder (UIResponderInputViewAdditions)

// Called and presented when object becomes first responder. Goes up the responder chain.
//鍵盤view.
@property (nullable, nonatomic, readonly, strong) __kindof UIView *inputView NS_AVAILABLE_IOS(3_2);
//鍵盤附加view
@property (nullable, nonatomic, readonly, strong) __kindof UIView *inputAccessoryView NS_AVAILABLE_IOS(3_2);

/// This method is for clients that wish to put buttons on the Shortcuts Bar, shown on top of the keyboard.
//這個(gè)方法是給客戶端--希望添加按鈕組在這個(gè)Shortcuts Bar.顯示在鍵盤的上面.
/// You may modify the returned inputAssistantItem to add to or replace the existing items on the bar.
//你應(yīng)該修改這個(gè)輸入輔助類目去添加或者替代已經(jīng)存在的子類目在這個(gè)bar上.
/// Modifications made to the returned UITextInputAssistantItem are reflected automatically.
//修改會(huì)導(dǎo)致UITextInputAssistantItem 會(huì)同步改變.
/// This method should not be overriden. Goes up the responder chain.
//這個(gè)方法不應(yīng)該被重寫.增加響應(yīng)鏈.
//輸入輔助類目.
@property (nonnull, nonatomic, readonly, strong) UITextInputAssistantItem *inputAssistantItem NS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED __WATCHOS_PROHIBITED;

// For viewController equivalents of -inputView and -inputAccessoryView
//對(duì)于控制器來(lái)說(shuō),inputView和inputAccessoryView是一樣的.
// Called and presented when object becomes first responder. Goes up the responder chain.
//訪問(wèn)和呈現(xiàn)當(dāng)對(duì)象成為第一響應(yīng)者.喚起響應(yīng)鏈.
//輸入控制器.
@property (nullable, nonatomic, readonly, strong) UIInputViewController *inputViewController NS_AVAILABLE_IOS(8_0);
//輸入輔助控制器.
@property (nullable, nonatomic, readonly, strong) UIInputViewController *inputAccessoryViewController NS_AVAILABLE_IOS(8_0);

/* When queried, returns the current UITextInputMode, from which the keyboard language can be determined.
//當(dāng)查詢時(shí),返回現(xiàn)在的UITextInputMode,--鍵盤語(yǔ)言決定的.

  • When overridden it should return a previously-queried UITextInputMode object, which will attempt to be
    //當(dāng)重寫它應(yīng)該返回一個(gè)預(yù)查尋的UITextInputMode對(duì)象--將會(huì)嘗試設(shè)置在app里面.但是不堅(jiān)持影響用戶的系統(tǒng)鍵盤設(shè)定.
  • set inside that app, but not persistently affect the user's system-wide keyboard settings. */
    //文本輸入模式.
    @property (nullable, nonatomic, readonly, strong) UITextInputMode textInputMode NS_AVAILABLE_IOS(7_0);
    /
    When the first responder changes and an identifier is queried, the system will establish a context to
  • track the textInputMode automatically. The system will save and restore the state of that context to
  • the user defaults via the app identifier. Use of -textInputMode above will supercede use of -textInputContextIdentifier. */
    // 存儲(chǔ)文本輸入模式
    @property (nullable, nonatomic, readonly, strong) NSString *textInputContextIdentifier NS_AVAILABLE_IOS(7_0);
    // This call is to remove stored app identifier state that is no longer needed.
    //移除指定文本輸入模式.
  • (void)clearTextInputContextIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(7_0);

// If called while object is first responder, reloads inputView, inputAccessoryView, and textInputMode. Otherwise ignored.
//當(dāng)對(duì)象是第一響應(yīng)者時(shí),可調(diào)用這個(gè)方法刷新.

  • (void)reloadInputViews NS_AVAILABLE_IOS(3_2);

@end

// These are pre-defined constants for use with the input property of UIKeyCommand objects.
//以下是一些預(yù)定義的常量為了用戶和輸入屬性--UIKeyCommand對(duì)象.
//向上光標(biāo)
UIKIT_EXTERN NSString *const UIKeyInputUpArrow NS_AVAILABLE_IOS(7_0);
//向下光標(biāo)
UIKIT_EXTERN NSString *const UIKeyInputDownArrow NS_AVAILABLE_IOS(7_0);
//左邊光標(biāo)
UIKIT_EXTERN NSString *const UIKeyInputLeftArrow NS_AVAILABLE_IOS(7_0);
//右邊光標(biāo).
UIKIT_EXTERN NSString *const UIKeyInputRightArrow NS_AVAILABLE_IOS(7_0);
//沒有光標(biāo).
UIKIT_EXTERN NSString *const UIKeyInputEscape NS_AVAILABLE_IOS(7_0);
//用戶事件傳遞(多設(shè)備)
@interface UIResponder (ActivityContinuation)
//用戶事件
@property (nullable, nonatomic, strong) NSUserActivity *userActivity NS_AVAILABLE_IOS(8_0);
//更新用戶事件

  • (void)updateUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);
    //存儲(chǔ)用戶事件
  • (void)restoreUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);
    @end

NS_ASSUME_NONNULL_END

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,919評(píng)論 6 502
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異孵延,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)亲配,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,567評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門尘应,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)惶凝,“玉大人,你說(shuō)我怎么就攤上這事犬钢〔韵剩” “怎么了?”我有些...
    開封第一講書人閱讀 163,316評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵玷犹,是天一觀的道長(zhǎng)混滔。 經(jīng)常有香客問(wèn)我,道長(zhǎng)歹颓,這世上最難降的妖魔是什么坯屿? 我笑而不...
    開封第一講書人閱讀 58,294評(píng)論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮巍扛,結(jié)果婚禮上愿伴,老公的妹妹穿的比我還像新娘。我一直安慰自己电湘,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,318評(píng)論 6 390
  • 文/花漫 我一把揭開白布鹅经。 她就那樣靜靜地躺著寂呛,像睡著了一般。 火紅的嫁衣襯著肌膚如雪瘾晃。 梳的紋絲不亂的頭發(fā)上贷痪,一...
    開封第一講書人閱讀 51,245評(píng)論 1 299
  • 那天,我揣著相機(jī)與錄音蹦误,去河邊找鬼劫拢。 笑死,一個(gè)胖子當(dāng)著我的面吹牛强胰,可吹牛的內(nèi)容都是我干的舱沧。 我是一名探鬼主播,決...
    沈念sama閱讀 40,120評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼偶洋,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼熟吏!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起涛碑,我...
    開封第一講書人閱讀 38,964評(píng)論 0 275
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤挥萌,失蹤者是張志新(化名)和其女友劉穎柒啤,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體帽氓,經(jīng)...
    沈念sama閱讀 45,376評(píng)論 1 313
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,592評(píng)論 2 333
  • 正文 我和宋清朗相戀三年俩块,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了黎休。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片浓领。...
    茶點(diǎn)故事閱讀 39,764評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖奋渔,靈堂內(nèi)的尸體忽然破棺而出镊逝,到底是詐尸還是另有隱情,我是刑警寧澤嫉鲸,帶...
    沈念sama閱讀 35,460評(píng)論 5 344
  • 正文 年R本政府宣布撑蒜,位于F島的核電站,受9級(jí)特大地震影響玄渗,放射性物質(zhì)發(fā)生泄漏座菠。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,070評(píng)論 3 327
  • 文/蒙蒙 一藤树、第九天 我趴在偏房一處隱蔽的房頂上張望浴滴。 院中可真熱鬧,春花似錦岁钓、人聲如沸升略。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,697評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)品嚣。三九已至,卻和暖如春钧大,著一層夾襖步出監(jiān)牢的瞬間翰撑,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,846評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工啊央, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留眶诈,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,819評(píng)論 2 370
  • 正文 我出身青樓瓜饥,卻偏偏與公主長(zhǎng)得像逝撬,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子乓土,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,665評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容