//
// 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