美文网首页
iOS13 ERROR

iOS13 ERROR

作者: 会飞的大西瓜v | 来源:发表于2020-04-02 14:53 被阅读0次
  1. 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];
    
}

相关文章

网友评论

      本文标题:iOS13 ERROR

      本文链接:https://www.haomeiwen.com/subject/kcexphtx.html