如何让UISwitch调用此函数:打开时为https://ghostbin.com/paste/y2xrc,关闭时返回FALSE。(我正在使用theos编译)
(我将开关设置为在Messages.app (MobileSMS.app)中显示"CKTranscriptCollectionViewController“内部,现在我想让它在打开或关闭时执行某些操作,这就是我在上面的链接中发布的内容)。
#import <UIKit/UIKit.h>
#import <ChatKit/ChatKit.h>
#import <ChatKit/CKConversation.h>
@interface CKTranscriptCollectionViewController : UIViewController
@property (nonatomic, strong) UISwitch *mySwitch;
- (void)loadView;
@end
%hook CKTranscriptCollectionViewController
- (void)viewDidLoad {
%orig;
UISwitch *mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 10, 51, 31)];
[mySwitch setOn:NO animated:YES];
[self.view addSubview:mySwitch];
}
%end发布于 2014-09-05 02:42:31
对于UISwitch,您应该为UIControlEventValueChanged添加一个目标
[mySwitch addTarget:self action:@selector(switchToggle) forControlEvents:UIControlEventValueChanged];代入你的目标并采取相应的行动。调用选择器时,您需要检查开关的值是什么。
发布于 2014-09-20 20:26:25
您可以尝试这样做:
[yourSwitchObject addTarget:self action:@selector(generateLegendaryMessage:) forControlEvents:UIControlEventValueChanged];
- (void)generateLegendaryMessage:(id)sender
{
NSLog("Its gonna be legen...... wait for it ...... dary !!!!!!!");
}https://stackoverflow.com/questions/25672466
复制相似问题