iOS开发UIResponder简介API
生活随笔
收集整理的這篇文章主要介紹了
iOS开发UIResponder简介API
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#import <Foundation/Foundation.h>
#import <UIKit/UIKitDefines.h>
#import <UIKit/UIEvent.h>
#import <UIKit/UIPasteConfigurationSupporting.h>NS_ASSUME_NONNULL_BEGIN@class UIPress;
@class UIPressesEvent;
//響應(yīng)者類(lèi)的按鍵命令類(lèi)類(lèi)目
@protocol UIResponderStandardEditActions <NSObject>
@optional
- (void)cut:(nullable id)sender NS_AVAILABLE_IOS(3_0);//剪切
- (void)copy:(nullable id)sender NS_AVAILABLE_IOS(3_0);//復(fù)制
- (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);//從左到右寫(xiě)入字符串
- (void)makeTextWritingDirectionRightToLeft:(nullable id)sender NS_AVAILABLE_IOS(5_0);//從右到左寫(xiě)入字符串
- (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);//減小字體大小@endNS_CLASS_AVAILABLE_IOS(2_0) @interface UIResponder : NSObject <UIResponderStandardEditActions>
//響應(yīng)鏈中負(fù)責(zé)傳遞事件的方法
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly, nullable) UIResponder *nextResponder;
#else
- (nullable UIResponder*)nextResponder;
#endif//一個(gè)響應(yīng)對(duì)象是否可以成為第一響應(yīng)者,可以用這個(gè)進(jìn)行判斷,默認(rèn)值為NO
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) BOOL canBecomeFirstResponder; // default is NO
#else
- (BOOL)canBecomeFirstResponder; // default is NO
#endif
//設(shè)置對(duì)象成為第一響應(yīng)者,成功返回YES;否則返回NO
- (BOOL)becomeFirstResponder;//是否可以辭去第一響應(yīng)者,默認(rèn)值為YES
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) BOOL canResignFirstResponder; // default is YES
#else
- (BOOL)canResignFirstResponder; // default is YES
#endif
//辭去第一響應(yīng)者 成功返回YES;否則返回NO
- (BOOL)resignFirstResponder;//判定一個(gè)響應(yīng)對(duì)象是否是第一響應(yīng)者
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) BOOL isFirstResponder;
#else
- (BOOL)isFirstResponder;
#endif//響應(yīng)觸摸事件
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;//手指按下的時(shí)候調(diào)用
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;//手指移動(dòng)的時(shí)候調(diào)用
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;//手指抬起的時(shí)候調(diào)用
- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;//取消(非正常離開(kāi)屏幕,意外中斷)
- (void)touchesEstimatedPropertiesUpdated:(NSSet<UITouch *> *)touches NS_AVAILABLE_IOS(9_1);// Apple Pencil 產(chǎn)生的 touch 事件的部分信息(如 Pencil 的方向等)傳遞到 iPad 或 iPhone 上會(huì)有一定的延時(shí)。
//UIKit 的回調(diào)方法 touchBegan 是立即產(chǎn)生的,其返回的參數(shù) touch 中包含了 Pencil 產(chǎn)生的額外信息,這個(gè)額外信息是有延時(shí)的。所以,首次回調(diào)時(shí)會(huì)給出額外信息的預(yù)估值,延時(shí)獲取真實(shí)值之后會(huì)調(diào)用 touchesEstimatedPropertiesUpdated 方法更新額外信息。//物理按鈕 深按API,一般用于遙控器
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);// 開(kāi)始按壓的時(shí)候調(diào)用
- (void)pressesChanged:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);// 按壓改變的時(shí)候調(diào)用
- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);// 按壓結(jié)束的時(shí)候調(diào)用
- (void)pressesCancelled:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event NS_AVAILABLE_IOS(9_0);// 當(dāng)系統(tǒng)發(fā)出取消按壓事件的時(shí)候調(diào)用//響應(yīng)移動(dòng)事件
- (void)motionBegan:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);//移動(dòng)事件開(kāi)始
- (void)motionEnded:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);//移動(dòng)事件結(jié)束
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);//移動(dòng)事件取消//響應(yīng)遠(yuǎn)程控制事件 一般用于耳機(jī)
- (void)remoteControlReceivedWithEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(4_0);//通過(guò)這個(gè)方法告訴UIMenuController它內(nèi)部應(yīng)該顯示什么內(nèi)容,”復(fù)制”、”粘貼”等
- (BOOL)canPerformAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(3_0);
////默認(rèn)的實(shí)現(xiàn)是調(diào)用canPerformAction:withSender:方法來(lái)確定對(duì)象是否可以調(diào)用action操作。如果我們想要重寫(xiě)目標(biāo)的選擇方式,則應(yīng)該重寫(xiě)這個(gè)方法。
- (nullable id)targetForAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(7_0);//UIResponder提供了一個(gè)只讀方法來(lái)獲取響應(yīng)鏈中共享的undo管理器,公共的事件撤銷(xiāo)管理者
@property(nullable, nonatomic,readonly) NSUndoManager *undoManager NS_AVAILABLE_IOS(3_0);@end//定義一個(gè)響應(yīng)者支持的快捷鍵
typedef NS_OPTIONS(NSInteger, UIKeyModifierFlags) {UIKeyModifierAlphaShift = 1 << 16,// Alppha+Shift鍵UIKeyModifierShift = 1 << 17,//Shift鍵UIKeyModifierControl = 1 << 18,//Control鍵UIKeyModifierAlternate = 1 << 19,//Alt鍵UIKeyModifierCommand = 1 << 20,//Command鍵UIKeyModifierNumericPad = 1 << 21,//Num鍵
} 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 (nullable,nonatomic,readonly) NSString *input;
//按鍵調(diào)節(jié)器
@property (nonatomic,readonly) UIKeyModifierFlags modifierFlags;
//按指定調(diào)節(jié)器鍵輸入字符串并設(shè)置事件
@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// Creates an key command that will _not_ be discoverable in the UI.
+ (UIKeyCommand *)keyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags action:(SEL)action;// Key Commands with a discoverabilityTitle _will_ be discoverable in the 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)//鍵盤(pán)輸入視圖(系統(tǒng)默認(rèn)的,可以自定義)
@property (nullable, nonatomic, readonly, strong) __kindof UIView *inputView NS_AVAILABLE_IOS(3_2);
//彈出鍵盤(pán)時(shí)附帶的視圖
@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.
/// You may modify the returned inputAssistantItem to add to or replace the existing items on the bar.
/// Modifications made to the returned UITextInputAssistantItem are reflected automatically.
/// 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;//鍵盤(pán)輸入視圖控制器 IOS8以后
@property (nullable, nonatomic, readonly, strong) UIInputViewController *inputViewController NS_AVAILABLE_IOS(8_0);
//彈出鍵盤(pán)時(shí)附帶的視圖的視圖控制器 IOS8以后
@property (nullable, nonatomic, readonly, strong) UIInputViewController *inputAccessoryViewController NS_AVAILABLE_IOS(8_0);//文本輸入模式
@property (nullable, nonatomic, readonly, strong) UITextInputMode *textInputMode NS_AVAILABLE_IOS(7_0);
//文本輸入模式標(biāo)識(shí)
@property (nullable, nonatomic, readonly, strong) NSString *textInputContextIdentifier NS_AVAILABLE_IOS(7_0);
//根據(jù)設(shè)置的標(biāo)識(shí)清除指定的文本輸入模式
+ (void)clearTextInputContextIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(7_0);//重新刷新鍵盤(pán)輸入視圖
- (void)reloadInputViews NS_AVAILABLE_IOS(3_2);@end// 按鍵輸入箭頭指向
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)
//用戶(hù)活動(dòng)
@property (nullable, nonatomic, strong) NSUserActivity *userActivity NS_AVAILABLE_IOS(8_0);
//更新用戶(hù)活動(dòng)
- (void)updateUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);
//恢復(fù)用戶(hù)活動(dòng)
- (void)restoreUserActivityState:(NSUserActivity *)activity NS_AVAILABLE_IOS(8_0);
@end#if TARGET_OS_IOS
@interface UIResponder (UIPasteConfigurationSupporting) <UIPasteConfigurationSupporting>
@end
#endifNS_ASSUME_NONNULL_END
?
轉(zhuǎn)載于:https://www.cnblogs.com/xianfeng-zhang/p/9466257.html
總結(jié)
以上是生活随笔為你收集整理的iOS开发UIResponder简介API的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux系统软件信息内核,系统,目录,
- 下一篇: ADC分类及参数