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);//减小字体大小 @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 //一个响应对象是否可以成为第一响应者,可以用这个进行判断,默认值为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 = << ,// Alppha+Shift键
UIKeyModifierShift = << ,//Shift键
UIKeyModifierControl = << ,//Control键
UIKeyModifierAlternate = << ,//Alt键
UIKeyModifierCommand = << ,//Command键
UIKeyModifierNumericPad = << ,//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
#endif NS_ASSUME_NONNULL_END
iOS开发UIResponder简介API的更多相关文章
- iOS开发之多媒体API(1)
iOS开发之多媒体API(1) 播放视频 视频文件介绍 视频格式可以分为适合本地播放的本地影像视频和适合在网络中播放的网络流媒体影像视频两大类.尽管后者在播放的稳定性和播放画面质量上可能没 ...
- iOS开发UITouch触摸API简介
1.UITouch简介 当用户触摸屏幕时,会创建一个UITouch对象: UITouch的作用保存着触摸相关的信息,比如触摸的位置.时间.阶段等: 当从开始到结束,系统会更新UITouch对象,结束时 ...
- iOS开发UIResponder之NSUndoManager
1.简介 UIResponder有个属性:NSUndoManager @property(nullable, nonatomic,readonly) NSUndoManager *undoManage ...
- iOS开发之多媒体API (转载)
视频格式可以分为适合本地播放的本地影像视频和适合在网络中播放的网络流媒体影像视频两大类.尽管后者在播放的稳定性和播放画面质量上可能没有前者 优秀,但网络流媒体影像视频的广泛传播性使之正被广泛应用于视频 ...
- iOS开发之多媒体API
播放视频 视频文件介绍 视频格式可以分为适合本地播放的本地影像视频和适合在网络中播放的网络流媒体影像视频两大类.尽管后者在播放的稳定性和播放画面质量上可能没有前者 优秀,但网络流媒体影像视频的广泛传播 ...
- iOS开发-多线程简介
多线程从概念上理解是指从软件或者硬件上实现多个线程并发执行的技术,简单点理解就是同一时间可以执行多个事情(比如说一边听歌一边码代码),听歌是一个线程,码代码是一个线程,如果是单核CPU的话,上面两个动 ...
- iOS开发中的Html解析方法
iOS开发中的Html解析方法 本文作者为大家介绍了在iOS开发中的Html解析方法,并同时提供了Demo代码的下载链接,Demo 解析了某个网站(具体可在代码中查看)的html网页,提取了图片以及标 ...
- iOS开发-Objective-C Block的实现方式
前言:我们可以把Block当作一个闭包函数,它可以访问外部变量和局部变量,但默认是不可以修改外部变量.你可以使用它来做回调方法,比起使用代理(Delegate)会更加直观.顺带一提,苹果很多的接口(A ...
- iOS开发UI篇—核心动画简介
转自:http://www.cnblogs.com/wendingding/p/3801036.html iOS开发UI篇—核心动画简介 一.简单介绍 Core Animation,中文翻译为核心动画 ...
随机推荐
- move_base 分层代价地图的作用(翻译)
A. 标准层 Static Map Layer:为了做全局规划,机器人需要一个超越其传感器的地图,以了解墙壁和其他静态障碍物的位置. 静态地图可以先用SLAM算法生成,也可以从架构图中创建. 当层 ...
- (转)即时通讯IM OpenFire源码学习之三:在Eclipse中构建源码
转:http://blog.csdn.net/huwenfeng_2011/article/details/43412617 源码搭建 下载地址: 地址:http://www.igniterealti ...
- C/S模式简单socket通信
TCP连接方式 sever.c #include <stdio.h>#include <stdlib.h>#include <sys/socket.h>#inclu ...
- C语言中的数据类型转换函数
头文件#include<stdlib.h> 1. 函数名: atof 功 能: 把字符串转换成浮点数 用 法: double atof(const char *nptr); 2.函数名: ...
- IIS身份验证和文件操作权限(二、匿名身份验证)
一.配置匿名身份验证 二.浏览站点 -- 操作文件 ①无操作权限 点击写入 ②有操作权限(IIS_IUSRS.Authenticated Users两个任选一个) 点击写入
- Windows下Cython使用(VS2017)
收到公众号推送文章“利用Cython为Python代码加速”后尝试在Windows平台下使用Cython,环境为Python3.5 + VS2017. 1. 简单尝试 1)新建hello.pyx文件, ...
- android应用的资源
应用资源可以分为两大类: 1.无法直接访问的原生资源,保存在asset目录下. 2.可以通过R资源清单类访问的资源,保存在res目录下. 资源的类型以及存储方式: android要求在res目录下用不 ...
- C语言结构体注意点
#include <stdio.h> int main() { /*************************************************** *定义结构体变量的 ...
- Raft——可理解的分布式一致性算法
Raft Understandable Distributed Consensus http://thesecretlivesofdata.com/raft/ 一个直观的动画,便于理解raft算法. ...
- cocos构建的android项目的返回键相应
@Override public boolean dispatchKeyEvent(KeyEvent event) { //返回键 cocosActivity不相应onbackPressed和onKe ...