< UIKit >

UIDragSession.h

2019-06-24  本文已影响0人  zhYx_

#if USE_UIKIT_PUBLIC_HEADERS || !__has_include(<UIKitCore/UIDragSession.h>)
//
//  UIDragSession.h
//  UIKit
//
//  Copyright © 2017-�2018 Apple Inc. All rights reserved.
//

#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKitDefines.h>

NS_ASSUME_NONNULL_BEGIN

@class UIDragItem, UIView;

/* 拖动/放置会话配置公共类 */



///!!!: 拖/放会话相关配置 <协议>
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, tvos) @protocol UIDragDropSession <NSObject>

/// 拖/放会话中的Item(处理Drop时,如果想以线性顺序显示Drop的项目,排序此数组,按顺序放置它们)
@property (nonatomic, readonly) NSArray<UIDragItem *> *items;

// 拖动的Item在指定视图中的位置
- (CGPoint)locationInView:(UIView *)view;

/// 拖动会话是否允许在同一个App中移动Item
@property (nonatomic, readonly) BOOL allowsMoveOperation;
/// 拖动会话是否只能在开始拖动的App中进行
@property (nonatomic, readonly, getter=isRestrictedToDraggingApplication) BOOL restrictedToDraggingApplication;

// typeIdentifiers(类型标识符数组)包含的类型是否有拖动会话中Item的类型
- (BOOL)hasItemsConformingToTypeIdentifiers:(NSArray<NSString *> *)typeIdentifiers;
// 拖动会话中是否至少有一个Item可以创建指定类的实例
- (BOOL)canLoadObjectsOfClass:(Class<NSItemProviderReading>)aClass;

@end



///!!!: 拖动会话相关配置 <协议>
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, tvos) @protocol UIDragSession <UIDragDropSession>

/// 为拖动会话添加自定义数据(仅对拖动会话开始的App可见)
@property (nonatomic, strong, nullable) id localContext;

@end



/* 放置会话进度指示器样式 <枚举> */
typedef NS_ENUM(NSUInteger, UIDropSessionProgressIndicatorStyle) {
    UIDropSessionProgressIndicatorStyleNone,    /// 无进度器样式
    UIDropSessionProgressIndicatorStyleDefault, /// 默认进度器样式
} API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, tvos);



///!!!: 放置会话相关配置 <协议>
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, tvos) @protocol UIDropSession <UIDragDropSession, NSProgressReporting>

/// 与此放置会话对应的拖动会话(如果拖动是在另一个App中启动的,则为nil)
@property (nonatomic, readonly, nullable) id<UIDragSession> localDragSession;
/// 放置会话进度指示器样式 (如果需要自定义进度指示器,需要设置成StyleNone,来隐藏系统进度UI;默认:UIDropSessionProgressIndicatorStyleDefault)
@property (nonatomic) UIDropSessionProgressIndicatorStyle progressIndicatorStyle;

/**
 为会话中的每个拖动项创建并加载aClass的新实例

 @param aClass 遵守NSItemProviderReading协议的类
 @param completion 加载所有对象后执行的回调
 @return 所有对象加载进度的总进度
 
 - 只能在 UIDropInteraction 的 - dropInteraction:performDrop: 代理方法中使用此方法
 - 用户将Item放入目标视图后调用此方法
 */
- (NSProgress *)loadObjectsOfClass:(Class<NSItemProviderReading>)aClass completion:(void(^)(NSArray<__kindof id<NSItemProviderReading>> *objects))completion;

@end



NS_ASSUME_NONNULL_END

#else
#import <UIKitCore/UIDragSession.h>
#endif

上一篇 下一篇

猜你喜欢

热点阅读