【发布时间】:2014-09-10 07:01:04
【问题描述】:
我正在尝试将 UIButton 放入 iPhone 的 MobileSMS.app(消息应用程序)中。它成功出现在视图中,但是当您按下它时,它当然会崩溃,因为它没有调用任何目标类并挂钩方法。我想挂钩的目标类和方法在下面的第二个代码中,如何在按下按钮时调用它? (我的主要目标是在对话视图中放置一个按钮,当点击它时它将强制发送短信而不是自动使用 iMessage。)
#import <UIKit/UIKit.h>
#import <ChatKit/ChatKit.h>
@interface CKTranscriptCollectionViewController : UIViewController
@end
%hook CKTranscriptCollectionViewController
-(void)loadView {
%orig;
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"SMS" forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, 50, 100);
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
-(void)buttonPressed {
NSLog(@"Button Pressed!");
}
%end
点击按钮时我想调用的类和方法(属于标题“ChatKit/CKConversation.h”):
%hook CKConversation
-(BOOL)forceMMS {
return TRUE;
}
%end
【问题讨论】:
标签: ios objective-c iphone jailbreak theos