拖放到`UICollectionView`占位符在IOS 11 Beta 4的

问题描述:

用于拖放到UICollectionView在IOS 11贝塔4.改变处于测试1-3中的API,代码看起来像:拖放到`UICollectionView`占位符在IOS 11 Beta 4的

let placeholderContext = coordinator.drop(
    item.dragItem, 
    toPlaceholderInsertedAt: indexPath, 
    withReuseIdentifier: "reuseID", 
    cellUpdateHandler: { _ in } 
) 

在beta 4中,引入了UICollectionViewDropPlaceholder。我的代码是

let placeholder = UICollectionViewDropPlaceholder(
    insertionIndexPath: indexPath, 
    reuseIdentifier: "reuseID" 
) 

let placeholderContext = coordinator.drop(item.dragItem, to: placeholder) 

我得到这个编译错误:

Undefined symbols for architecture arm64: 
    "_OBJC_CLASS_$_UICollectionViewDropPlaceholder", referenced from: 
     objc-class-ref in StickerLibraryViewController.o 
ld: symbol(s) not found for architecture arm64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
note: symbol(s) not found for architecture arm64 
error: linker command failed with exit code 1 (use -v to see invocation) 

除了没有使用占位符,直到测试5,任何人对如何在测试4得到这个工作的任何想法?

谢谢!

直到在Beta 5中解决这个问题,我最终通过将其放入Objective-C运行时来解决此问题。

在对象 - 头......

NS_ASSUME_NONNULL_BEGIN 

@interface RKNFactory : NSObject 

- (UICollectionViewDropPlaceholder*)placeholderForIndexPath:(NSIndexPath*)indexPath resuseIdentifier:(NSString*)reuseIdentifier; 

@end 

NS_ASSUME_NONNULL_END 

在实施......

@import ObjectiveC.runtime; 

@implementation RKNFactory 

- (UICollectionViewDropPlaceholder*)placeholderForIndexPath:(NSIndexPath*)indexPath resuseIdentifier:(NSString*)reuseIdentifier { 

    SEL initSelector = NSSelectorFromString(@"initWithInsertionIndexPath:reuseIdentifier:"); 
    Class placeholderClass = NSClassFromString(@"UICollectionViewDropPlaceholder"); 
    return [[placeholderClass alloc] performSelector:initSelector withObject:indexPath withObject:reuseIdentifier]; 
} 

@end 

再从银行代码...

return RKNFactory().placeholder(for: indexPath, resuseIdentifier: reuseIdentifier) 

我有一个类似的问题,本地身份验证没有在模拟器架构上编译时,它是在测试版。

如果您从构建设置中的有效体系结构中删除arm64(或关闭“构建所有体系结构”),它会编译吗?

如果他们为模拟器编译了这个符号,但是把它留给了arm64,唯一的解决方案可能是防止它在arm64上编译,并且现在只在模拟器上测试它。

您还可以将代码临时包装在“#if block”中,以防止编译器在构建arm64时查看它。

最后,如果您正在为iOS 11以下的任何iOS版本构建,请务必尝试将它们暂时关闭,以防忘记标记API可用性(这可能会让编译器提供更有用的消息)。

+0

不幸的是,它没有任何工作建筑。只要将它放在#if块中就行不通了(我所有的拖放代码都是围绕使用占位符设计的)。幸运的是,进入Obj-C运行时间后,它一直运行到beta 5。 –