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