我用 cycript 捕捉到WeChat进程 可以调用self.navigationController进行调整开发 self 用地址代替 但是 写入Tweak.xm中确无法调用self.navigationController。 Tweak.xm 也引入过#import <UIKit/UIKit.h>和#import <Foundation/Foundation.h> 请哪位大神指导下
类型转换一下self
不是很明白 我是尝试逆向微信试试看 就 BaseMsgContentViewController 这个类 具体代码 是这个 您帮我看看 我是小白 我把 能想到的引用都写进去了
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface MMUIViewController : UIViewController
@end
@interface MMSearchBarDisplayController : MMUIViewController
@end
@interface BaseMsgContentViewControlle:MMSearchBarDisplayController
-(void)AsyncSendMessage:(id)arg1;
@end
%hook BaseMsgContentViewController
-(void)viewDidAppear:(BOOL)animated
{
%orig;
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"这是测试" message:
[NSString stringWithFormat:@"%@",self]
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
[self.navigationController popViewControllerAnimated:YES];
}
%end
[self.navigationController popViewControllerAnimated:YES];
----------------->>>>>>>>
很多种方法,这种应该是其中之一
[(UIViewController*)[self performSelector:@selector(navigationController)] popViewControllerAnimated:YES];
你这么写的话,编译报什么错?
我的Tweak.xm 是这样的
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface MMUIViewController : UIViewController
@end
@interface MMSearchBarDisplayController : MMUIViewController
@end
@interface BaseMsgContentViewControlle:MMSearchBarDisplayController
-(void)AsyncSendMessage:(id)arg1;
%hook BaseMsgContentViewController
-(void)viewDidAppear:(BOOL)animated
{
%orig;
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"这是测试" message:
[NSString stringWithFormat:@"%@",self]
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
[self.navigationController popViewControllerAnimated:YES];
}
%end
报的错误是
按照之前大佬提示把
[self.navigationController popViewControllerAnimated:YES];
改成
[(UIViewController*)[self performSelector:@selector(navigationController)] popViewControllerAnimated:YES];
是不是我缺少引用了什么
大哥, popViewControllerAnimated:
是 UINavigationController
的
navigationController
是微信自己定义的
https://www.google.com/search?Search&q=popViewControllerAnimated%3A
不是吧,UIViewController
里有个navigationController
的property
你那么写应该是没问题的,你是写的@interface @end
,而不是@class
,不知道为什么还会报这个错;但是我看编译报错里Tweak.xm的行数,跟你实际贴的代码行数好像对不上。你把完整的Tweak.xm贴出来看看?(注意用markdown语法)
这样?那是我错了
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
// #import “UIViewController.h”
@interface MMUIViewController : UIViewController
@end
@interface MMSearchBarDisplayController : MMUIViewController
@end
@interface BaseMsgContentViewControlle:MMSearchBarDisplayController
-(void)AsyncSendMessage:(id)arg1;
%hook BaseMsgContentViewController
-(void)viewDidAppear:(BOOL)animated
{
%orig;
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@“这是测试” message:
[NSString stringWithFormat:@"%@",self]
delegate:self cancelButtonTitle:@“OK” otherButtonTitles: nil];
[alert show];
[alert release];
[self.navigationController popViewControllerAnimated:YES];
}
%end
试试这样行不行
新建.h文件,把类的声明都放到.h文件中 在给BaseMsgContentViewControlle
加个navigationController
属性
@interface BaseMsgContentViewControlle:MMSearchBarDisplayController
@property(nonatomic,readonly,strong) UINavigationController *navigationController;
-(void)AsyncSendMessage:(id)arg1;
@end
可以试试把7到11行删掉,然后把13行的MMSearchBarDisplayController
改成UIViewController
两个import都去掉试试?
我添加了 还是不行 之前我也试过 之前找到UIViewController 的@property(nonatomic,readonly,strong) UINavigationController *navigationController;还是不行
一样的 是不是 和之前配置theos的问题
[[self navigationController] popViewControllerAnimated:YES];
代码看起来是没问题的,你试试楼上的方法呢