2012-09-03 32 views
0

我有一个按钮在锁屏显示一个警告时被触摸,我只是玩这个东西,并试图做到这一点,但是当我触摸按钮它崩溃并respring以安全模式进入。我在我的iPhone.Here狄奥运行它是我的代码:按钮不能在锁屏工作

#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 
+0

给我们一些日志。安装来自Cydia的Crash Reporter,然后通过SSH尾部-f/var/log/syslog获取正在运行的“实时”报告。它会在终端窗口中打印日志。 –

+0

这是如何,我试图ssh我的iphone,然后-f/var/log/syslog,但说命令没有找到,在崩溃记者应用程序我有一个崩溃日志你需要跳板崩溃日志吗? – user1628700

+0

我不认为你把尾巴命令。 “tail -f/var/log/syslog”。让我看看这里的崩溃输入。我们可以使用跳板故障日志,但“飞行中”可以更容易地获取崩溃日志。 –

回答

0

先试着调试,看看功能被称为与否。

然后也是它崩溃,然后尝试使用自动释放

UIAlertView *theAlert = [[[UIAlertView alloc] initWithTitle:@"Title of Alert" message:@"Message of Alert" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil] autorelease] ; 
[theAlert show]; 
+0

虽然这不会帮助找到崩溃的来源。最多它会告诉我们该方法是否被调用。基于OP,我会说它确实会被调用并在那里崩溃。 –

0

你需要新的%(V @ :)之前,你的空虚;

%new([email protected]:) 
-(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]; 

} 
+1

为什么这是必要的? – jturolla