动态设置是否锁屏等

参考

[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;



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值