[英]How can I get my UISwitch to call this method? (using theos)
我如何讓我的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
對於UISwitch,應為UIControlEventValueChanged
添加目標
[mySwitch addTarget:self action:@selector(switchToggle) forControlEvents:UIControlEventValueChanged];
替代您的目標並采取相應的行動。 您需要檢查調用選擇器時開關的值。
您可以嘗試以下方法:
[yourSwitchObject addTarget:self action:@selector(generateLegendaryMessage:) forControlEvents:UIControlEventValueChanged];
- (void)generateLegendaryMessage:(id)sender
{
NSLog("Its gonna be legen...... wait for it ...... dary !!!!!!!");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.