{"id":16,"date":"2022-12-16T09:32:36","date_gmt":"2022-12-16T01:32:36","guid":{"rendered":"http:\/\/www.qirimi.com\/?p=16"},"modified":"2023-01-20T11:36:36","modified_gmt":"2023-01-20T03:36:36","slug":"ios%e5%bc%80%e5%8f%91-%e4%b9%8b-uiresponder%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"http:\/\/www.qirimi.com\/index.php\/2022\/12\/16\/ios%e5%bc%80%e5%8f%91-%e4%b9%8b-uiresponder%e8%af%a6%e8%a7%a3\/","title":{"rendered":"iOS\u5f00\u53d1 \u4e4b UIResponder\u8be6\u89e3"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/\/\n\/\/  UIResponder.h\n\/\/  ZMHeaderFile\n\/\/\n\/\/  Created by ZengZhiming on 2017\/4\/18.\n\/\/  Copyright \u00a9 2017\u5e74 \u83dc\u9e1f\u57fa\u5730. All rights reserved.\n\/\/\n\/\/  \u8be6\u89e3 UIResponder.h\n\/\/  Version iOS 10.3\n\/\/\n \n#import &lt;Foundation\/Foundation.h>\n#import &lt;UIKit\/UIKitDefines.h>\n#import &lt;UIKit\/UIEvent.h>\n \nNS_ASSUME_NONNULL_BEGIN\n \n@class UIPress;\n@class UIPressesEvent;\n \n#pragma mark - UIResponderStandardEditActions\u534f\u8bae\u5b9a\u4e49\n \n@protocol UIResponderStandardEditActions &lt;NSObject>\n@optional\n\/** \u526a\u5207\u4e8b\u4ef6 *\/\n- (void)cut:(nullable id)sender NS_AVAILABLE_IOS(3_0);\n\/** \u590d\u5236\u4e8b\u4ef6 *\/\n- (void)copy:(nullable id)sender NS_AVAILABLE_IOS(3_0);\n\/** \u7c98\u8d34\u4e8b\u4ef6 *\/\n- (void)paste:(nullable id)sender NS_AVAILABLE_IOS(3_0);\n\/** \u9009\u62e9\u4e8b\u4ef6 *\/\n- (void)select:(nullable id)sender NS_AVAILABLE_IOS(3_0);\n\/** \u5168\u9009\u4e8b\u4ef6 *\/\n- (void)selectAll:(nullable id)sender NS_AVAILABLE_IOS(3_0);\n\/** \u5220\u9664\u4e8b\u4ef6 *\/\n- (void)delete:(nullable id)sender NS_AVAILABLE_IOS(3_2);\n\/** \u4ece\u5de6\u5230\u53f3\u5199\u5165\u5b57\u7b26\u4e32(\u5c45\u5de6) *\/\n- (void)makeTextWritingDirectionLeftToRight:(nullable id)sender NS_AVAILABLE_IOS(5_0);\n\/** \u4ece\u53f3\u5230\u5de6\u5199\u5165\u5b57\u7b26\u4e32(\u5c45\u53f3) *\/\n- (void)makeTextWritingDirectionRightToLeft:(nullable id)sender NS_AVAILABLE_IOS(5_0);\n\/** \u5207\u6362\u5b57\u4f53\u4e3a\u9ed1\u4f53(\u7c97\u4f53) *\/\n- (void)toggleBoldface:(nullable id)sender NS_AVAILABLE_IOS(6_0);\n\/** \u5207\u6362\u5b57\u4f53\u4e3a\u659c\u4f53 *\/\n- (void)toggleItalics:(nullable id)sender NS_AVAILABLE_IOS(6_0);\n\/** \u7ed9\u6587\u5b57\u6dfb\u52a0\u4e0b\u5212\u7ebf *\/\n- (void)toggleUnderline:(nullable id)sender NS_AVAILABLE_IOS(6_0);\n \n\/** \u589e\u52a0\u5b57\u4f53\u5927\u5c0f *\/\n- (void)increaseSize:(nullable id)sender NS_AVAILABLE_IOS(7_0);\n\/** \u51cf\u5c0f\u5b57\u4f53\u5927\u5c0f *\/\n- (void)decreaseSize:(nullable id)sender NS_AVAILABLE_IOS(7_0);\n \n@end\n \n#pragma mark - UIResponder\u7c7b\u5b9a\u4e49\n \nNS_CLASS_AVAILABLE_IOS(2_0) @interface UIResponder : NSObject &lt;UIResponderStandardEditActions>\n \n#pragma mark - \u54cd\u5e94\u8005\u76f8\u5173\u65b9\u6cd5\n \n\/** \u83b7\u53d6\u4e0b\u4e00\u4e2a\u54cd\u5e94\u8005 *\/\n#if UIKIT_DEFINE_AS_PROPERTIES\n@property(nonatomic, readonly, nullable) UIResponder *nextResponder;\n#else\n- (nullable UIResponder *)nextResponder;\n#endif\n \n\/** \u662f\u5426\u5141\u8bb8\u6210\u4e3a\u7b2c\u4e00\u54cd\u5e94\u8005\u3002\u9ed8\u8ba4\u8fd4\u56deNO *\/\n#if UIKIT_DEFINE_AS_PROPERTIES\n@property(nonatomic, readonly) BOOL canBecomeFirstResponder;\n#else\n- (BOOL)canBecomeFirstResponder;\n#endif\n\/** \u8bbe\u7f6e\u6210\u4e3a\u7b2c\u4e00\u54cd\u5e94\u8005 *\/\n- (BOOL)becomeFirstResponder;\n \n\/** \u662f\u5426\u5141\u8bb8\u653e\u5f03\u7b2c\u4e00\u54cd\u5e94\u8005\u3002\u9ed8\u8ba4\u8fd4\u56deYES *\/\n#if UIKIT_DEFINE_AS_PROPERTIES\n@property(nonatomic, readonly) BOOL canResignFirstResponder;\n#else\n- (BOOL)canResignFirstResponder;\n#endif\n\/** \u8bbe\u7f6e\u653e\u5f03\u7b2c\u4e00\u54cd\u5e94\u8005 *\/\n- (BOOL)resignFirstResponder;\n \n\/** \u5224\u65ad\u5bf9\u8c61\u662f\u5426\u662f\u7b2c\u4e00\u54cd\u5e94\u8005 *\/\n#if UIKIT_DEFINE_AS_PROPERTIES\n@property(nonatomic, readonly) BOOL isFirstResponder;\n#else\n- (BOOL)isFirstResponder;\n#endif\n \n#pragma mark - \u89e6\u6478\u76f8\u5173\u65b9\u6cd5\uff0c\u4e00\u822c\u7528\u4e8e\u54cd\u5e94\u5c4f\u5e55\u89e6\u6478\n\/** \u624b\u6307\u6309\u4e0b\u65f6\u54cd\u5e94 *\/\n- (void)touchesBegan:(NSSet&lt;UITouch *> *)touches withEvent:(nullable UIEvent *)event;\n\/** \u624b\u6307\u79fb\u52a8\u65f6\u54cd\u5e94 *\/\n- (void)touchesMoved:(NSSet&lt;UITouch *> *)touches withEvent:(nullable UIEvent *)event;\n\/** \u624b\u6307\u62ac\u8d77\u65f6\u54cd\u5e94 *\/\n- (void)touchesEnded:(NSSet&lt;UITouch *> *)touches withEvent:(nullable UIEvent *)event;\n\/** \u53d6\u6d88(\u610f\u5916\u4e2d\u65ad, \u5982:\u7535\u8bdd, \u7cfb\u7edf\u8b66\u544a\u7a97\u7b49) *\/\n- (void)touchesCancelled:(NSSet&lt;UITouch *> *)touches withEvent:(nullable UIEvent *)event;\n\/** 3DTouch\u54cd\u5e94(iOS9.1\u540e\u4f7f\u7528) *\/\n- (void)touchesEstimatedPropertiesUpdated:(NSSet&lt;UITouch *> *)touches NS_AVAILABLE_IOS(9_1);\n \n#pragma mark - \u6df1\u6309\u76f8\u5173\u65b9\u6cd5\uff0c\u4e00\u822c\u7528\u4e8e\u9065\u63a7\u5668\u6309\u952e\u54cd\u5e94\n\/** \u624b\u6307\u6309\u538b\u5f00\u59cb\u65f6\u54cd\u5e94 *\/\n- (void)pressesBegan:(NSSet&lt;UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);\n\/** \u624b\u6307\u6309\u538b\u4f4d\u7f6e\u79fb\u52a8\u65f6\u54cd\u5e94 *\/\n- (void)pressesChanged:(NSSet&lt;UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);\n\/** \u624b\u6307\u62ac\u8d77\u63a5\u53d7\u6309\u538b\u65f6\u54cd\u5e94 *\/\n- (void)pressesEnded:(NSSet&lt;UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);\n\/** \u6309\u538b\u53d6\u6d88(\u610f\u5916\u4e2d\u65ad, \u5982:\u7535\u8bdd, \u7cfb\u7edf\u8b66\u544a\u7a97\u7b49) *\/\n- (void)pressesCancelled:(NSSet&lt;UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);\n \n#pragma mark - \u52a0\u901f\u76f8\u5173\u65b9\u6cd5\uff0c\u4e00\u822c\u7528\u4e8e\u6447\u4e00\u6447\u3001\u8fd0\u52a8\u4e8b\u4ef6\u76d1\u542c\u7b49\n\/** \u5f00\u59cb\u52a0\u901f *\/\n- (void)motionBegan:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);\n\/** \u7ed3\u675f\u52a0\u901f *\/\n- (void)motionEnded:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);\n\/** \u52a0\u901f\u53d6\u6d88\uff08\u610f\u5916\u4e2d\u65ad, \u5982:\u7535\u8bdd, \u7cfb\u7edf\u8b66\u544a\u7a97\u7b49\uff09 *\/\n- (void)motionCancelled:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);\n \n\/** \u8fdc\u7a0b\u63a7\u5236\u4e8b\u4ef6 *\/\n- (void)remoteControlReceivedWithEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(4_0);\n \n\/** \u8fd4\u56deUIMenuController\u9700\u8981\u663e\u793a\u7684\u63a7\u4ef6(\u5982\uff1a\u590d\u5236\uff0c\u7c98\u8d34\u7b49) *\/\n- (BOOL)canPerformAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(3_0);\n \n\/** \u8fd4\u56de\u54cd\u5e94\u7684\u64cd\u4f5c\u76ee\u6807\u5bf9\u8c61 *\/\n- (nullable id)targetForAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(7_0);\n \n\/** \u83b7\u53d6\u54cd\u5e94\u94fe\u5c31\u8fd1\u5171\u4eab\u64a4\u6d88\u7ba1\u7406 *\/\n@property(nullable, nonatomic,readonly) NSUndoManager *undoManager NS_AVAILABLE_IOS(3_0);\n \n@end\n \n\/** \u5feb\u6377\u4e3b\u952e\u679a\u4e3e *\/\ntypedef NS_OPTIONS(NSInteger, UIKeyModifierFlags) {\n    UIKeyModifierAlphaShift     = 1 &lt;&lt; 16,  \/\/!&lt; Alpha+Shift\u952e.\n    UIKeyModifierShift          = 1 &lt;&lt; 17,  \/\/!&lt; Shift\u952e.\n    UIKeyModifierControl        = 1 &lt;&lt; 18,  \/\/!&lt; Control\u952e.\n    UIKeyModifierAlternate      = 1 &lt;&lt; 19,  \/\/!&lt; Alt\u952e.\n    UIKeyModifierCommand        = 1 &lt;&lt; 20,  \/\/!&lt; Command\u952e.\n    UIKeyModifierNumericPad     = 1 &lt;&lt; 21,  \/\/!&lt; Num\u952e.\n} NS_ENUM_AVAILABLE_IOS(7_0);\n \n#pragma mark - \u5feb\u6377\u952e\u5bf9\u8c61\n \nNS_CLASS_AVAILABLE_IOS(7_0) @interface UIKeyCommand : NSObject &lt;NSCopying, NSSecureCoding>\n \n\/** \u521d\u59cb\u5316\u5bf9\u8c61 *\/\n- (instancetype)init NS_DESIGNATED_INITIALIZER;\n\/** \u521d\u59cb\u5316\u5bf9\u8c61 *\/\n- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;\n \n\/** \u83b7\u53d6\u5feb\u6377\u8f85\u952e\uff08\u5982\u5feb\u6377\u547d\u4ee4\u3010Command+A\u3011\u4e2d\u7684 A \u952e\uff09 *\/\n@property (nonatomic,readonly) NSString *input;\n\/** \u83b7\u53d6\u5feb\u6377\u4e3b\u952e\uff08\u5982\u5feb\u6377\u547d\u4ee4\u3010Command+A\u3011\u4e2d\u7684 Command \u952e\uff09 *\/\n@property (nonatomic,readonly) UIKeyModifierFlags modifierFlags;\n\/** \u663e\u793a\u7ed9\u7528\u6237\u7684\u5feb\u6377\u952e\u6807\u9898 *\/\n@property (nullable,nonatomic,copy) NSString *discoverabilityTitle NS_AVAILABLE_IOS(9_0);\n \n\/** \u521b\u5efa\u4e00\u4e2a\u5feb\u6377\u952e\u547d\u4ee4 *\/\n+ (UIKeyCommand *)keyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags action:(SEL)action;\n \n\/** \u521b\u5efa\u4e00\u4e2a\u5feb\u6377\u952e\u547d\u4ee4 *\/\n+ (UIKeyCommand *)keyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags action:(SEL)action discoverabilityTitle:(NSString *)discoverabilityTitle NS_AVAILABLE_IOS(9_0);\n \n@end\n \n#pragma mark - \u54cd\u5e94\u5feb\u6377\u547d\u4ee4\n \n@interface UIResponder (UIResponderKeyCommands)\n\/** \u8fd4\u56de\u5feb\u6377\u952e\u547d\u4ee4\u6570\u7ec4 *\/\n@property (nullable,nonatomic,readonly) NSArray&lt;UIKeyCommand *> *keyCommands NS_AVAILABLE_IOS(7_0);\n@end\n \n@class UIInputViewController;\n@class UITextInputMode;\n@class UITextInputAssistantItem;\n \n#pragma mark - \u8f93\u5165\u89c6\u56fe\n \n@interface UIResponder (UIResponderInputViewAdditions)\n \n\/** \u952e\u76d8\u8f93\u5165\u89c6\u56fe(\u7cfb\u7edf\u9ed8\u8ba4\u7684,\u53ef\u4ee5\u81ea\u5b9a\u4e49) *\/\n@property (nullable, nonatomic, readonly, strong) __kindof UIView *inputView NS_AVAILABLE_IOS(3_2);\n\/** \u5f39\u51fa\u952e\u76d8\u65f6\u9644\u5e26\u7684\u89c6\u56fe *\/\n@property (nullable, nonatomic, readonly, strong) __kindof UIView *inputAccessoryView NS_AVAILABLE_IOS(3_2);\n \n\/** \u8f93\u5165\u52a9\u624b\u914d\u7f6e\u952e\u76d8\u7684\u5feb\u6377\u65b9\u5f0f\u680f\u65f6\u4f7f\u7528 *\/\n@property (nonnull, nonatomic, readonly, strong) UITextInputAssistantItem *inputAssistantItem NS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED __WATCHOS_PROHIBITED;\n \n\/** \u952e\u76d8\u8f93\u5165\u89c6\u56fe\u63a7\u5236\u5668 *\/\n@property (nullable, nonatomic, readonly, strong) UIInputViewController *inputViewController NS_AVAILABLE_IOS(8_0);\n\/** \u5f39\u51fa\u952e\u76d8\u65f6\u9644\u5e26\u7684\u89c6\u56fe\u7684\u89c6\u56fe\u63a7\u5236\u5668 *\/\n@property (nullable, nonatomic, readonly, strong) UIInputViewController *inputAccessoryViewController NS_AVAILABLE_IOS(8_0);\n \n\/** \u6587\u672c\u8f93\u5165\u6a21\u5f0f *\/\n@property (nullable, nonatomic, readonly, strong) UITextInputMode *textInputMode NS_AVAILABLE_IOS(7_0);\n \n\/** \u6587\u672c\u8f93\u5165\u6a21\u5f0f\u6807\u8bc6 *\/\n@property (nullable, nonatomic, readonly, strong) NSString *textInputContextIdentifier NS_AVAILABLE_IOS(7_0);\n\/** \u6839\u636e\u8bbe\u7f6e\u7684\u6807\u8bc6\u6e05\u9664\u6307\u5b9a\u7684\u6587\u672c\u8f93\u5165\u6a21\u5f0f *\/\n+ (void)clearTextInputContextIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(7_0);\n \n\/** \u91cd\u65b0\u5237\u65b0\u952e\u76d8\u8f93\u5165\u89c6\u56fe *\/\n- (void)reloadInputViews NS_AVAILABLE_IOS(3_2);\n \n@end\n \n\/** \u7279\u6b8a\u5feb\u6377\u8f85\u952e\u5b9a\u4e49 *\/\nUIKIT_EXTERN NSString *const UIKeyInputUpArrow         NS_AVAILABLE_IOS(7_0); \/\/!&lt; \u4e0a\u6309\u952e.\nUIKIT_EXTERN NSString *const UIKeyInputDownArrow       NS_AVAILABLE_IOS(7_0); \/\/!&lt; \u4e0b\u6309\u952e.\nUIKIT_EXTERN NSString *const UIKeyInputLeftArrow       NS_AVAILABLE_IOS(7_0); \/\/!&lt; \u5de6\u6309\u952e.\nUIKIT_EXTERN NSString *const UIKeyInputRightArrow      NS_AVAILABLE_IOS(7_0); \/\/!&lt; \u53f3\u6309\u952e\nUIKIT_EXTERN NSString *const UIKeyInputEscape          NS_AVAILABLE_IOS(7_0); \/\/!&lt; Esc\u6309\u952e.\n \n#pragma mark - \u54cd\u5e94\u8005\u6d3b\u52a8\n \n@interface UIResponder (ActivityContinuation)\n\/** \u7528\u6237\u6d3b\u52a8 *\/\n@property (nullable, nonatomic, strong) NSUserActivity *userActivity NS_AVAILABLE_IOS(8_0);\n\/** \u66f4\u65b0\u7528\u6237\u6d3b\u52a8 *\/\n- (void)updateUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);\n\/** \u6062\u590d\u7528\u6237\u6d3b\u52a8 *\/\n- (void)restoreUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);\n@end\n \nNS_ASSUME_NONNULL_END\n \n \n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[2,4],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-3","tag-ios","tag-uiresponder"],"_links":{"self":[{"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":1,"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"predecessor-version":[{"id":17,"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/posts\/16\/revisions\/17"}],"wp:attachment":[{"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qirimi.com\/index.php\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}