NSItemProvider 拖拽item
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
if (@available(iOS 11.0, *)) {
UIDragInteraction *dragInteraction = [[UIDragInteraction alloc] initWithDelegate:self];
dragInteraction.enabled = YES;
[self addInteraction:dragInteraction];
}
}
return self;
}
#pragma mark - UIDragInteractionDelegate
- (nonnull NSArray<UIDragItem *> *)dragInteraction:(nonnull UIDragInteraction *)interaction itemsForBeginningSession:(nonnull id<UIDragSession>)session NS_AVAILABLE_IOS(11.0) {
NSItemProvider *itemProvider = [[NSItemProvider alloc] initWithObject:self.tagSpecial];
UIDragItem *dragItem = [[UIDragItem alloc] initWithItemProvider:itemProvider];
return @[dragItem];
}
本文标题:NSItemProvider 拖拽item
本文链接:https://www.haomeiwen.com/subject/kkjrwrtx.html
网友评论