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);
    //复制
  • (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

//下一个响应者属性
@property(nonatomic, readonly, nullable) UIResponder *nextResponder;

else

//下一个响应者

  • (nullable UIResponder*)nextResponder;

endif

if UIKIT_DEFINE_AS_PROPERTIES

//是否能成为第一响应者,默认为NO
@property(nonatomic, readonly) BOOL canBecomeFirstResponder; // default is NO

else

//是否能成为第一响应者,默认为NO //方法

  • (BOOL)canBecomeFirstResponder; // default is NO

endif

//成为第一响应者,成功返回Yes.

  • (BOOL)becomeFirstResponder;

if UIKIT_DEFINE_AS_PROPERTIES

//是否可以辞去第一响应者,默认为YES.
@property(nonatomic, readonly) BOOL canResignFirstResponder; // default is YES

else

//是否可以辞去第一响应者,默认为YES. //方法

  • (BOOL)canResignFirstResponder; // default is YES

endif

//辞去第一响应者,成功返回YES.

  • (BOOL)resignFirstResponder;

if UIKIT_DEFINE_AS_PROPERTIES

//是否是第一响应者.
@property(nonatomic, readonly) BOOL isFirstResponder;

else

//是否是第一响应者.

  • (BOOL)isFirstResponder;

endif

// Generally, all responders which do custom touch handling should override all four of these methods.
//一般来说,所有的响应者--做自定义触摸处理的应该重写一下四个方法.
// Your responder will receive either touchesEnded:withEvent: or touchesCancelled:withEvent: for each
// touch it is handling (those touches it received in touchesBegan:withEvent:).
//你的响应者将会接收touchesEnded:withEvent: or touchesCancelled:withEvent:
对于每一个触摸.他是处理(those touches it received in touchesBegan:withEvent:).
// *** You must handle cancelled touches to ensure correct behavior in your application. Failure to
//你必须手动取消触摸去确定正确的行为在你的app上.
// do so is very likely to lead to incorrect behavior or crashes.
//失败去做所有是很可能的导致错误的行为甚至崩溃.
//触摸开始

  • (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
    //触摸移动
  • (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
    //触摸结束
  • (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
    //触摸取消
  • (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;
    //预估触摸.
  • (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.
//一般来说,所有的响应者--自定义按压应该重写下面四个方法.
// Your responder will receive either pressesEnded:withEvent or pressesCancelled:withEvent: for each
// press it is handling (those presses it received in pressesBegan:withEvent:).//同上差不多.
//按压改变将会被按压--模拟值触发.
// 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);
    //按压结束
  • (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);
    //手势开始
  • (void)motionBegan:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
    //手势结束
  • (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);
    //远程控制接受者.
  • (void)remoteControlReceivedWithEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(4_0);
    //是否可以执行给定动作.
  • (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.
    //允许转移动作的执行者.
  • (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;
    //修改标志
    @property (nonatomic,readonly) UIKeyModifierFlags modifierFlags;
    //发现可用的标题
    @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
//这个UIKeyCommands的动作应该接收一个单独的sender,作为在UIResponderStandardEditActions之上.
// Creates an key command that will not be discoverable in the UI.
//创建一个key command 将不会被发现在ui层次.
//初始化key command .

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

// Key Commands with a discoverabilityTitle will be discoverable in the UI.
///创建一个key command 将会被发现在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.
//这个方法是给客户端--希望添加按钮组在这个Shortcuts Bar.显示在键盘的上面.
/// You may modify the returned inputAssistantItem to add to or replace the existing items on the bar.
//你应该修改这个输入辅助类目去添加或者替代已经存在的子类目在这个bar上.
/// Modifications made to the returned UITextInputAssistantItem are reflected automatically.
//修改会导致UITextInputAssistantItem 会同步改变.
/// This method should not be overriden. Goes up the responder chain.
//这个方法不应该被重写.增加响应链.
//输入辅助类目.
@property (nonnull, nonatomic, readonly, strong) UITextInputAssistantItem *inputAssistantItem NS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED __WATCHOS_PROHIBITED;

// For viewController equivalents of -inputView and -inputAccessoryView
//对于控制器来说,inputView和inputAccessoryView是一样的.
// Called and presented when object becomes first responder. Goes up the responder chain.
//访问和呈现当对象成为第一响应者.唤起响应链.
//输入控制器.
@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.
//当查询时,返回现在的UITextInputMode,--键盘语言决定的.

  • When overridden it should return a previously-queried UITextInputMode object, which will attempt to be
    //当重写它应该返回一个预查寻的UITextInputMode对象--将会尝试设置在app里面.但是不坚持影响用户的系统键盘设定.
  • 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. */
    // 存储文本输入模式
    @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.
//当对象是第一响应者时,可调用这个方法刷新.

  • (void)reloadInputViews NS_AVAILABLE_IOS(3_2);

@end

// These are pre-defined constants for use with the input property of UIKeyCommand objects.
//以下是一些预定义的常量为了用户和输入属性--UIKeyCommand对象.
//向上光标
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);
//没有光标.
UIKIT_EXTERN NSString *const UIKeyInputEscape NS_AVAILABLE_IOS(7_0);
//用户事件传递(多设备)
@interface UIResponder (ActivityContinuation)
//用户事件
@property (nullable, nonatomic, strong) NSUserActivity *userActivity NS_AVAILABLE_IOS(8_0);
//更新用户事件

  • (void)updateUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);
    //存储用户事件
  • (void)restoreUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);
    @end

NS_ASSUME_NONNULL_END

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,456评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,370评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,337评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,583评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,596评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,572评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,936评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,595评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,850评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,601评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,685评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,371评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,951评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,934评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,167评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,636评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,411评论 2 342

推荐阅读更多精彩内容