日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iOS开发UIResponder简介API

發布時間:2025/3/17 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iOS开发UIResponder简介API 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#import <Foundation/Foundation.h> #import <UIKit/UIKitDefines.h> #import <UIKit/UIEvent.h> #import <UIKit/UIPasteConfigurationSupporting.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);//減小字體大小@endNS_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//一個響應對象是否可以成為第一響應者,可以用這個進行判斷,默認值為NO #if UIKIT_DEFINE_AS_PROPERTIES @property(nonatomic, readonly) BOOL canBecomeFirstResponder; // default is NO #else - (BOOL)canBecomeFirstResponder; // default is NO #endif //設置對象成為第一響應者,成功返回YES;否則返回NO - (BOOL)becomeFirstResponder;//是否可以辭去第一響應者,默認值為YES #if UIKIT_DEFINE_AS_PROPERTIES @property(nonatomic, readonly) BOOL canResignFirstResponder; // default is YES #else - (BOOL)canResignFirstResponder; // default is YES #endif //辭去第一響應者 成功返回YES;否則返回NO - (BOOL)resignFirstResponder;//判定一個響應對象是否是第一響應者 #if UIKIT_DEFINE_AS_PROPERTIES @property(nonatomic, readonly) BOOL isFirstResponder; #else - (BOOL)isFirstResponder; #endif//響應觸摸事件 - (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);// Apple Pencil 產生的 touch 事件的部分信息(如 Pencil 的方向等)傳遞到 iPad 或 iPhone 上會有一定的延時。 //UIKit 的回調方法 touchBegan 是立即產生的,其返回的參數 touch 中包含了 Pencil 產生的額外信息,這個額外信息是有延時的。所以,首次回調時會給出額外信息的預估值,延時獲取真實值之后會調用 touchesEstimatedPropertiesUpdated 方法更新額外信息。//物理按鈕 深按API,一般用于遙控器 - (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);//通過這個方法告訴UIMenuController它內部應該顯示什么內容,”復制”、”粘貼”等 - (BOOL)canPerformAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(3_0); ////默認的實現是調用canPerformAction:withSender:方法來確定對象是否可以調用action操作。如果我們想要重寫目標的選擇方式,則應該重寫這個方法。 - (nullable id)targetForAction:(SEL)action withSender:(nullable id)sender NS_AVAILABLE_IOS(7_0);//UIResponder提供了一個只讀方法來獲取響應鏈中共享的undo管理器,公共的事件撤銷管理者 @property(nullable, nonatomic,readonly) NSUndoManager *undoManager NS_AVAILABLE_IOS(3_0);@end//定義一個響應者支持的快捷鍵 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; //按鍵調節器 @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// 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)//鍵盤輸入視圖(系統默認的,可以自定義) @property (nullable, nonatomic, readonly, strong) __kindof UIView *inputView NS_AVAILABLE_IOS(3_2); //彈出鍵盤時附帶的視圖 @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;//鍵盤輸入視圖控制器 IOS8以后 @property (nullable, nonatomic, readonly, strong) UIInputViewController *inputViewController NS_AVAILABLE_IOS(8_0); //彈出鍵盤時附帶的視圖的視圖控制器 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); //文本輸入模式標識 @property (nullable, nonatomic, readonly, strong) NSString *textInputContextIdentifier NS_AVAILABLE_IOS(7_0); //根據設置的標識清除指定的文本輸入模式 + (void)clearTextInputContextIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(7_0);//重新刷新鍵盤輸入視圖 - (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) //用戶活動 @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#if TARGET_OS_IOS @interface UIResponder (UIPasteConfigurationSupporting) <UIPasteConfigurationSupporting> @end #endifNS_ASSUME_NONNULL_END

?

轉載于:https://www.cnblogs.com/xianfeng-zhang/p/9466257.html

總結

以上是生活随笔為你收集整理的iOS开发UIResponder简介API的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。