下载

点击下载

配置工程

添加framework

WebKit.framework

网络使用权限

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>NSAllowsArbitraryLoads</key>
	<true/>
</dict>
</plist>
-ObjC

添加Url Types

Figure 1: 示意图

Figure 1: 示意图

代码使用

初始化

[[BlackHole sharedInstance] onStart:@"20190121230000"];

启动判断

if([[BlackHole sharedInstance] checkErrors]) {
    NSString *error = [BlackHole sharedInstance].error;
    viewController = [[BlackHole sharedInstance] showError:error];
    // Set RootViewController to window
    if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
    {
	// warning: addSubView doesn't work on iOS6
	[window addSubview: viewController.view];
    }
    else
    {
	// use this method on ios6
	[window setRootViewController:viewController];
    }

} else {

    // 游戏原来的启动
}

[[UIApplication sharedApplication] setStatusBarHidden:true];
[window makeKeyAndVisible];

生命周期处理

- (void)applicationDidBecomeActive:(UIApplication *)application {
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */

    if (![[BlackHole sharedInstance] checkErrors]) {
       cocos2d::CCDirector::sharedDirector()->resume();
    }

}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
     If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
     */
    if (![[BlackHole sharedInstance] checkErrors]) {
	cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
    }

}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    /*
     Called as part of  transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
     */
    if (![[BlackHole sharedInstance] checkErrors]) {
	cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
    }

}

测试需求

7天前

45天前

45天后