您的位置:首页 > 其它

iPhone/iPad程序 如何 禁止自动休眠

2012-05-08 16:00 337 查看
//禁止自动休眠可以通过这一句话搞定:

[UIApplication sharedApplication].idleTimerDisabled=YES;

//当然一定要慎用,记着退出程序时把自动休眠功能开启


UIApplication sharedApplication].idleTimerDisabled=NO;

phonegap程序在Classes文件夹下的MainViewController.m中进行相关设置

#pragma UIWebDelegate implementation

- (void) webViewDidFinishLoad:(UIWebView*) theWebView

{

// only valid if ___PROJECTNAME__-Info.plist specifies a protocol to handle

if (self.invokeString)

{

// this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready

NSString* jsString = [NSString
stringWithFormat:@"var invokeString = \"%@\";",
self.invokeString];

[theWebView stringByEvaluatingJavaScriptFromString:jsString];

}

// Black base color for background matches the native apps

theWebView.backgroundColor = [UIColor
blackColor];

[UIApplication
sharedApplication].idleTimerDisabled =
YES;//这里是相关代码

return [super
webViewDidFinishLoad:theWebView];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: