w***@qq.com
w***@qq.com
  • 发布:2017-02-13 10:49
  • 更新:2017-02-13 16:47
  • 阅读:4262

【已解决】怎么从iOS原生界面跳转回到html页面呢

分类:5+ SDK

我通过这个代码,跳转到iOS原生界面。

// NewViewController为应用内创建的原生的ViewController类名,所调用页面的内容需要在原生代码中完成  
var newVCobj = plus.ios.newObject("NewViewController");  
var UIApplicationClass = plus.ios.importClass("UIApplication");  
var UIAppObj = UIApplicationClass.sharedApplication();  
var del = plus.ios.invoke(UIAppObj,"delegate");  
// 如果当前应用delegate对象包含UIWindow对象并且变量名命名为“window”可以这么写,  
// 否则需要根据实际代码情况修改  
// 应用的delegate对象也可以添加一个返回UIViewController的方法  
var appWindowObj = plus.ios.invoke(del,"window");  
var appRootController = plus.ios.invoke(appWindowObj,"rootViewController");  
plus.ios.invoke(appRootController,"presentViewController:animated:completion:",newVCobj,"YES",null);

但是怎么跳转回去呢?我试了打开webview好像不行,求指导。
有找到过Android的回答,但是找不到iOS的

//这个是Android的  
Button btn = (Button)findViewById(R.id.button);  
btn.setOnClickListener(new View.OnClickListener(){  
        public void onClick(View v){  
                Intent intent=new Intent();  
                intent.setClass(Second.this, io.dcloud.PandoraEntry.class);  
                startActivity(intent);  
        }  
 });

============一番探索后=======
找到了一份代码……,可以运作的噢!

//  
//  xViewController.m  
//  HBuilder-Hello  
//  
//  Created by ljx on 17/2/12.  
//  Copyright © 2017年 DCloud. All rights reserved.  
//  

#import "xViewController.h"  

#import "PDRToolSystem.h"  
#import "PDRToolSystemEx.h"  
#import "PDRCoreAppFrame.h"  
#import "PDRCoreAppManager.h"  
@interface xViewController ()  

@end  

@implementation xViewController  

- (void)viewDidLoad {  
    [super viewDidLoad];  

    // Do any additional setup after loading the view from its nib.  
}  

- (void)didReceiveMemoryWarning {  
    [super didReceiveMemoryWarning];  
    // Dispose of any resources that can be recreated.  
}  
- (IBAction)MY:(id)sender {  
    //[self dismissViewControllerAnimated:YES completion:nil];  
    NSLog(@"FFF");  
    // 获取PDRCore句柄  
    PDRCore* pCoreHandle = [PDRCore Instance];  
    if (pCoreHandle != nil)  
    {  
        // 设置Core启动方式  
        [pCoreHandle startAsWebClient];  

        // 设置拼写Webview将要打开文件的url  
        NSString* pFilePath = [NSString stringWithFormat:@"file://%@/%@", [NSBundle mainBundle].bundlePath, @"Pandora/apps/HelloH5/www/plus/audio.html"];  

        CGRect StRect = CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height - 20);  

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

        // 设置webview的Appframe  
        [pCoreHandle.appManager.activeApp.appWindow registerFrame:appFrame];  

        // 将AppFrame设置为当前View的Subview  
        [self.view addSubview:appFrame];  
    }  
}  

/*  
#pragma mark - Navigation  

// In a storyboard-based application, you will often want to do a little preparation before navigation  
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {  
    // Get the new view controller using [segue destinationViewController].  
    // Pass the selected object to the new view controller.  
}  
*/  

@end  
2017-02-13 10:49 负责人:无 分享
已邀请:
w***@qq.com

w***@qq.com (作者)

有人吗?求助。

w***@qq.com

w***@qq.com (作者)


[self dismissViewControllerAnimated:YES completion:nil];  
``  
这个可以关闭当前页回到html界面。但如果进入多级原生节目应该就不行
  • 慕容清思

    这行代码写在什么地方呢

    2019-10-22 17:34

该问题目前已经被锁定, 无法添加新回复