UIResponder定义

2017-03-21  本文已影响268人  李某lkb

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

@end

NS_CLASS_AVAILABLE_IOS(2_0) @interface UIResponder : NSObject <UIResponderStandardEditActions>

if UIKIT_DEFINE_AS_PROPERTIES

//下一个响应者属性
@property(nonatomic, readonly, nullable) UIResponder *nextResponder;

else

//下一个响应者

endif

if UIKIT_DEFINE_AS_PROPERTIES

//是否能成为第一响应者,默认为NO
@property(nonatomic, readonly) BOOL canBecomeFirstResponder; // default is NO

else

//是否能成为第一响应者,默认为NO //方法

endif

//成为第一响应者,成功返回Yes.

if UIKIT_DEFINE_AS_PROPERTIES

//是否可以辞去第一响应者,默认为YES.
@property(nonatomic, readonly) BOOL canResignFirstResponder; // default is YES

else

//是否可以辞去第一响应者,默认为YES. //方法

endif

//辞去第一响应者,成功返回YES.

if UIKIT_DEFINE_AS_PROPERTIES

//是否是第一响应者.
@property(nonatomic, readonly) BOOL isFirstResponder;

else

//是否是第一响应者.

endif

// Generally, all responders which do custom touch handling should override all four of these methods.
//一般来说,所有的响应者--做自定义触摸处理的应该重写一下四个方法.
// Your responder will receive either touchesEnded:withEvent: or touchesCancelled:withEvent: for each
// touch it is handling (those touches it received in touchesBegan:withEvent:).
//你的响应者将会接收touchesEnded:withEvent: or touchesCancelled:withEvent:
对于每一个触摸.他是处理(those touches it received in touchesBegan:withEvent:).
// *** You must handle cancelled touches to ensure correct behavior in your application. Failure to
//你必须手动取消触摸去确定正确的行为在你的app上.
// do so is very likely to lead to incorrect behavior or crashes.
//失败去做所有是很可能的导致错误的行为甚至崩溃.
//触摸开始

// Generally, all responders which do custom press handling should override all four of these methods.
//一般来说,所有的响应者--自定义按压应该重写下面四个方法.
// Your responder will receive either pressesEnded:withEvent or pressesCancelled:withEvent: for each
// press it is handling (those presses it received in pressesBegan:withEvent:).//同上差不多.
//按压改变将会被按压--模拟值触发.
// 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.//同上差不多.
//按压开始.

@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>
//初始化

// The action for UIKeyCommands should accept a single (id)sender, as do the UIResponderStandardEditActions above
//这个UIKeyCommands的动作应该接收一个单独的sender,作为在UIResponderStandardEditActions之上.
// Creates an key command that will not be discoverable in the UI.
//创建一个key command 将不会被发现在ui层次.
//初始化key command .

// Key Commands with a discoverabilityTitle will be discoverable in the UI.
///创建一个key command 将会被发现在ui层次.

@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.
//这个方法是给客户端--希望添加按钮组在这个Shortcuts Bar.显示在键盘的上面.
/// You may modify the returned inputAssistantItem to add to or replace the existing items on the bar.
//你应该修改这个输入辅助类目去添加或者替代已经存在的子类目在这个bar上.
/// Modifications made to the returned UITextInputAssistantItem are reflected automatically.
//修改会导致UITextInputAssistantItem 会同步改变.
/// 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;

// For viewController equivalents of -inputView and -inputAccessoryView
//对于控制器来说,inputView和inputAccessoryView是一样的.
// Called and presented when object becomes first responder. Goes up the responder chain.
//访问和呈现当对象成为第一响应者.唤起响应链.
//输入控制器.
@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.
//当查询时,返回现在的UITextInputMode,--键盘语言决定的.

// If called while object is first responder, reloads inputView, inputAccessoryView, and textInputMode. Otherwise ignored.
//当对象是第一响应者时,可调用这个方法刷新.

@end

// These are pre-defined constants for use with the input property of UIKeyCommand objects.
//以下是一些预定义的常量为了用户和输入属性--UIKeyCommand对象.
//向上光标
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);
//更新用户事件

NS_ASSUME_NONNULL_END

上一篇下一篇

猜你喜欢

热点阅读