- IOS13 hook UICollectionView Delegate崩溃会报
TUICandidateView collectionView:didSelectItemAtIndexPath: unrecognized selector sent to instance 0x2802a4c60
解决:
- (void)zg_setDelegate:(id<UICollectionViewDelegate>)delegate {
[self zg_setDelegate:delegate];
if([NSStringFromClass([delegate class]) isEqualToString:@"TUICandidateGrid"]){
return;
}
NSObject *obg = (NSObject *)delegate;
if(![obg isKindOfClass:[NSObject class]]){
return;
}
SEL sel = @selector(collectionView:didSelectItemAtIndexPath:);
[obg aspect_hookSelector:sel withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> aspectInfo){
NSArray *arr = aspectInfo.arguments;
if(arr.count>1){
[self zg_collectionView:arr[0] didSelectItemAtIndexPath:arr[1]];
}
} error:nil];
}
网友评论