Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cordova in swift #32

Open
cisen opened this issue Aug 19, 2018 · 0 comments
Open

cordova in swift #32

cisen opened this issue Aug 19, 2018 · 0 comments
Labels

Comments

@cisen
Copy link
Owner

cisen commented Aug 19, 2018

注意:

  1. CDVViewController只能作为self.window?.rootViewController?
  2. 使用pod添加好后,还要添加bridge-header.h
#ifndef bridge_header_h
#define bridge_header_h
#import <Cordova/CDVViewController.h>

#endif /* bridge_header_h */

另外在Build Setting里面搜索bridge,找到Objective-C Bridging Header添加bridge-header.h文件

例子

import UIKit
import ReactiveCocoa
import Cordova

class CordovaSubView: CDVViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.addSubViews()
        self.webView.backgroundColor = UIColor.red;
        let path = Bundle.main.path(forResource: "www/login", ofType:"html")
        let urlStr = URL.init(fileURLWithPath: path!)
        print(urlStr)
//        self.webViewEngine.load(URLRequest(url: URL(string: "http://m.jd.com")!))
        self.webViewEngine.load(URLRequest(url: urlStr))
    }
    
    private func addSubViews() {
//        let vc = CDVViewController()
//        vc.view.frame = UIScreen.main.bounds
        // UIWindow(frame: UIScreen.main.bounds)
//        self.view.addSubview(vc.view)
        //创建UIScrollView
        let scrollV=UIScrollView(frame: CGRect(x:100,y:100,width:50,height:50))
        SpeechModal.init().beginSpeech()
        scrollV.backgroundColor=UIColor.red
        self.view.addSubview(scrollV)
    }
}

在appdelegate.swift文件添加self.window?.rootViewController = CordovaSubView()语句即能运行

@cisen cisen added the ios label May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant