我在锁屏上有一个按钮可以在触摸时显示警报,我只是在玩这个东西并尝试这样做,但是当我触摸按钮时它会崩溃并重新进入安全模式。我在我的 iPhone 中使用 theos 运行它。这是我的代码:
#import <UIKit/UIKit.h>
@interface SBAwayView : UIView
@end
@interface SBAwayController
UIButton *myButton;
-(void)unlockWithSound : (BOOL)sound;
@end
%hook SBAwayController
-(id)lock{
SBAwayView *v = MSHookIvar<id>(self, "_awayView");
myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(21, 80, 100, 35);
[myButton setTitle:@"My Button" forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(myButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[v addSubview:myButton];
%orig;
}
-(void)myButtonPressed{
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"Title of Alert" message:@"Message of Alert" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
}
%end