%hook添加了一个弹出框,单击弹出框中的选项不会触发该方法

问题描述

当我单击弹出窗口中的“确定”按钮时,我想在执行hook方法之前执行逻辑,但是没有执行。

@interface fmObject
-(void)print;
@end

%hook WMHomeVC
- (void)shopItemTouched:(id)arg1 {
    UIAlertController *alertvc = [UIAlertController alertControllerWithTitle:@"确认要买吗" message:@"" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
   
        %orig;
        
    }];
     
    [alertvc addAction:cancle];
    [alertvc addAction:confirm];
    
    [(id)self presentViewController:alertvc animated:true completion:nil];

}

运行该程序后,仅弹出一个弹出框,并且单击弹出框中的“确定”按钮不会执行先前的操作 我试图添加一个打印日志,以查看它是否真正出现在此关闭中。

@interface fmObject
-(void)print;
@end

%hook WMHomeVC
- (void)shopItemTouched:(id)arg1 {
    UIAlertController *alertvc = [UIAlertController alertControllerWithTitle:@"确认要买吗" message:@"" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * `_Nonnull` action) {
       
        NSLog(@"当前线程为 ---------------------------------%@",[NSThread currentThread]);
        %orig;
        
    }];
     
    [alertvc addAction:cancle];
    [alertvc addAction:confirm];
    
    [(id)self presentViewController:alertvc animated:true completion:nil];

}

我发现日志中有输出,它确实进入了此关闭,但是%orig没有执行先前的逻辑。有什么问题吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)