逞英雄
逞英雄
  • 发布:2020-01-07 10:51
  • 更新:2020-01-07 13:41
  • 阅读:919

ios WebViewController使用PDRCoreAppFrame加载h5页面,怎么退出

分类:5+ SDK
iOS

现在调用mui.back方法的时候直接黑屏

2020-01-07 10:51 负责人:无 分享
已邀请:
逞英雄

逞英雄 (作者)

只能自己写一个NSObject,然后在mui.back中调用原生的方法

这是js调取原生方法的代码

checkAuth = plus.ios.importClass("h5Quote");   
checkAuthEnvEnable = new checkAuth();  
zhichi = checkAuthEnvEnable.returnAction();

这是原生中关闭页面的代码

  • (void)returnAction{
    UIViewController * top = [self topMostController];
    [top dismissViewControllerAnimated:YES completion:^{
    }];
    // [self.navigationController popViewControllerAnimated:true];
    }
  • 逞英雄 (作者)

    发现这个方法不行 因为使用了dismissViewControllerAnimated 发现把最开始的viewcontrol给dis掉了,虽然可以返回了,但是返回以后页面就空白了

    2020-01-07 11:45

逞英雄

逞英雄 (作者)

使用js获取到当前显示的UIViewController对象

function getViewController(){  
        var currentWebview = plus.ios.currentWebview();  
        //UIViewController类对象  
        var UIViewController = plus.ios.invoke("UIViewController", "class");  
        while(currentWebview){  
            var responder = plus.ios.invoke(currentWebview, "nextResponder");  
            if (plus.ios.invoke(responder, "isKindOfClass:", UIViewController)) {  
                return responder;  
            }  
            currentWebview = plus.ios.invoke(currentWebview, "superview");  
        }  
        return null;  
    }

然后把获取到的UIViewController 使用js方法传到原生的returnAction方法中

mui.back = function() {  
    checkAuth = plus.ios.importClass("h5Quote");   
    checkAuthEnvEnable = new checkAuth();  
    zhichi = checkAuthEnvEnable.returnAction(getViewController());  
};

原生中returnAction的代码

- (void)returnAction:(UIViewController*) uiview{  
    [uiview dismissViewControllerAnimated:YES completion:^{}];  
}

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