動態設定是否鎖屏等

來源:互聯網
上載者:User

參考

[1]http://stackoverflow.com/questions/832940/programmatically-lock-and-unlock-iphone-screen

[2]http://stackoverflow.com/questions/4476777/how-to-set-lock-screen-wallpaper-and-ringtone-programmatically-in-iphone?rq=1

[3]http://stackoverflow.com/questions/1679814/iphone-phone-goes-to-sleep-even-if-idletimerdisabled-is-yes

[4]https://github.com/kennytm/iphone-private-frameworks/blob/master/GraphicsServices/GSEvent.h

沒有公開的API用來處理是否鎖屏,旋轉等,以下方法前提都是針對越獄手機。

註:以下方法都未驗證可用性、相容性

1.方法一

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

需要在 didFinishLaunchingWithOptions 調用,如果還是不行,嘗試:

[[UIApplication sharedApplication] setIdleTimerDisabled:NO];[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

參考[3]

2.方法二 

It can be done by caling GSEventLockDevice (); from your app. This function can be found in GraphicsServices.framework.

調用 GSEventLockDevice (); 實現鎖屏,

調用 GSEventResetIdleTimer();可以重設空閑時間,實現禁止鎖屏

另外還有個方法 GSEventResetIdleDuration(inta,intb);
不知道怎麼用的

3.方法三 ,下面代碼是讀入ringtone設定,將key改為“”即可。

不好意思,我還未找到 記錄自動鎖屏時間 的plist 和key

The following code can be used to read the actual ringtone title of custom ringtones (synced by iTunes).NSMutableDictionary *custDict = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/private/var/mobile/Media/iTunes_Control/iTunes/Ringtones.plist"];NSMutableDictionary *dictionary = [custDict objectForKey:@"Ringtones"];NSArray *keys = [dictionary allKeys];id key = [keys objectAtIndex:indexPath.row];NSMutableDictionary *customRingtone = [dictionary objectForKey:key];NSString *name = [customRingtone objectForKey:@"Name"];cell.textLabel.text = name;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.