html5 sdkios,IOS集成5+SDK

//在工程的AppDelegate类的添加代码,当应用启动时设置5+SDK的运行模式

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

// 设置当前SDK运行模式

return [PDRCore initEngineWihtOptions:launchOptions withRunMode: PDRCoreRunModeWebviewClient];

}

//在应用退出时添加销毁5+SDK运行环境

- (void)applicationWillTerminate:(UIApplication *)application{

// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

[PDRCore destoryEngine];

}

当前控制器中

// 启动5+运行环境

1)、widget集成方式

-(void)Start5pEngineAsWidget{

PDRCore *h5Engine = [PDRCore Instance];

CGRect newRect =CGRectMake(0, -StatusBarHeight, SCREENWIDTH, SCREENHEIGHT+StatusBarHeight);

_containerView = [[UIView alloc] initWithFrame:newRect]; _containerView.autoresizingMask =UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;

// 设置5+内核的Delegate,5+API在修改状态风格和应用是否全屏时会调用 h5Engine.coreDeleagete = self;

h5Engine.persentViewController =self;

[self.view addSubview:_containerView];

// 设置WebApp所在的目录,该目录下必须有mainfest.json

NSString* pWWWPath = [[[NSBundle mainBundle] bundlePath]stringByAppendingPathComponent:@"Pandora/apps/H57DE8278/www/"];

// 设置5+SDK运行的View

[h5Engine setContainerView:_containerView];

// 传入参数可以在页面中通过plus.runtime.arguments参数获取

NSString* pArgus = @"id=plus.runtime.arguments";

// 启动该应用

pAppHandle = [[[PDRCore Instance] appManager]openAppAtLocation:pWWWPath withIndexPath:@"index.html" withArgs:pArgus withDelegate:nil];

}

2)、webview集成方式

// 启动5+运行环境

-(void)Start5pEngineAsWidget

{

PDRCore* pCoreHandle = [PDRCore Instance];

if (pCoreHandle != nil)

{

NSString * pFilePath = [NSString stringWithFormat:@"file://%@/%@", [NSBundle mainBundle].bundlePath, @"Pandora/apps/H57DE8278/www/index.html#/home/first"];

[pCoreHandle start];

// 如果路径中包含中文,或Xcode工程的targets名为中文则需要对路径进行编码

// NSString * pFilePath1 = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes( kCFAllocatorDefault, (CFStringRef)pFilePath, NULL, NULL, kCFStringEncodingUTF8 ));

// 用户在集成5+SDK时,需要在5+内核初始化时设置当前的集成方式,

if (@available(iOS 11.0, *)) {

CGRect StRect = CGRectMake(0, StatusBarHeight, SCREENWIDTH, SCREENHEIGHT-StatusBarHeight-BottomHeight);

appFrame = [[PDRCoreAppFrame alloc] initWithName:@"WebViewID1" loadURL:pFilePath frame:StRect];

} else {

CGRect StRect = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT-BottomHeight);

appFrame = [[PDRCoreAppFrame alloc] initWithName:@"WebViewID1" loadURL:pFilePath frame:StRect];

}

if (appFrame) {

[pCoreHandle.appManager.activeApp.appWindow registerFrame:appFrame];

[self.view addSubview:appFrame];

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值