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];
}
[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];
}
相关文章推荐
- VC如何禁止自动屏保,休眠等节电模式
- 如何让你的iphone程序支援ipad.
- 如何在程序中判断硬件的机型(是ipad还是iphone/ipod touch)
- 如何禁止Win7系统IE浏览器自动启动程序
- [转]如何在移动设备程序中嵌入盈利广告,开始挣钱了 android iphone ipad 多平台支持
- 如何是iPad/iPhone程序满屏显示【也就是没有上面的电量条】
- 如何屏蔽和隐藏Win10更新程序提示禁止Win8.1自动更新
- 关于iphone/ipad同步,如何避免同步后目录和程序的顺序混乱
- 如何设置图片以及plist文件,使能够自动识别ipad以及iphone
- 如何使用Windbg自动抓取禁止使用调试器程序的dump
- 如何使用Windbg自动抓取禁止使用调试器程序的dump
- 如何禁止或暂停Windows的自动屏保、休眠等节电模式
- iPhone、iPhone4、iPad 程序启动画面的总结
- iPhone & iPad程序运行流程浅谈
- Xcode 4:如何将for iPhone的xib转变为for iPad
- 如何编写一个自动投票程序
- Win7如何禁止某个程序联网?
- 如何清理ipod touch iPhone ipad的“其他”文件
- iOS开发 - Xcode如何更换iPhone或iPad模拟器的类型
- iphone/ipad如何获取本机UDID