美文网首页
AipCaptureCardVC 导航栏问题

AipCaptureCardVC 导航栏问题

作者: AlexLi_ | 来源:发表于2019-10-15 17:43 被阅读0次

    解决办法一:之前有看到百度AI社区里有人说删掉项目中UINavigationController+FDFullscreenPopGesture.h

    解决办法二:AOP 修改 AipCaptureCardVC 控制器中的 ViewDidLoad 代码

    🔪 有人说可以自定义,我没找到...
    🔪 还有人说可以继承,我继承使用后会报错...
    🔪 因为比较笨,只能想到 AOP 解决了
    🔪 修改导航栏代码你们自己看,爱咋写咋写,主要能改到就行

    close@2x.png close@3x.png
    
    pod 'Aspects'
    -------------------
    #import <Aspects/Aspects.h>
    #import "UINavigationController+FDFullscreenPopGesture.h"
    -------------------
    
    @implementation UIViewController(SJAipCaptureCardVC)
    
    + (void)load {
        NSError *error;
        [UIViewController aspect_hookSelector:@selector(viewDidLoad) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> aspectInfo) {
            UIViewController *vc = aspectInfo.instance;
            [vc aop_viewDidLoad];
        } error:&error];
        if (error) NSLog(@"%@", error);
    }
    
    - (void)aop_viewDidLoad {
        if([NSStringFromClass(self.class) isEqualToString:@"AipCaptureCardVC"]){
            NSLog(@"ViewController+AOP aop_viewDidLoad class = %@",NSStringFromClass(self.class));
            self.fd_prefersNavigationBarHidden = true;
    //        self.fd_prefersNavigationBarHidden = false;
    //        UIBarButtonItem *leftItem= [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"SJAipCaptureCardVC_close"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(clickAction)];
    //        self.navigationItem.leftBarButtonItem = leftItem;
        }
    }
    
    -(void)clickAction{
        [self dismissViewControllerAnimated:true completion:nil];
    }
    
    
    @end
    
    

    相关文章

      网友评论

          本文标题:AipCaptureCardVC 导航栏问题

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