2012-09-19 250 views
0

我是新開發jailbroaken iphone應用程序。我想在鎖屏上添加我自己的視圖,例如按鈕,並執行一些簡單的任務,但我不知道要使用哪種api或函數。我可以通過使用特殊模板(如編寫自定義通知小部件)來做到這一點嗎?或者在特定視圖上添加子視圖?如何在鎖定屏幕上添加自定義視圖?

+0

沒人?爲什麼投票下來? –

+1

你有沒有[看着這個問題呢](http://stackoverflow.com/a/11602574/119114)?熟悉這些類型的調整通常是很好的信息。 – Nate

+0

非常感謝。這應該工作。我已經放棄了Springboard頭文件,現在我正在尋找控制鎖定屏幕的類。 –

回答

0

這是我的標誌代碼:

#import <UIKit/UIKit.h> 
#import <SpringBoard/SBAwayController.h> 
%hook SBAwayController 
- (void)lock 
{ 
    %orig; 

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    btn.frame = CGRectMake(10, 100, 280, 50); 
    [btn setTitle:@"Hello Notification" forState:UIControlStateNormal]; 
    UITapGestureRecognizer *singleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(unlock)] autorelease]; 
    [btn addGestureRecognizer:singleTap]; 
    [[[objc_getClass("SBAwayController") sharedAwayController] awayView] addSubview:btn]; 

    return; 
} 
%end 

當我鎖定屏幕,按鈕被添加到鎖屏。