0

I have an IOS app which shows a UIWebview , i want inside webview a button that permit users to go another view controller inside app that contain native code .. any suggestions ??

thanks in advance ..

<html>
    <head>
        <script type='text/javascript'>
           
            function locationChange()
            {
                window.location = 'ios:VoiceRecorder';
            }
        </script>
    </head>
    <body style='overflow-x:hidden;overflow-y:hidden;'>
        <h2 style = "font-size:16px;" align='center'>Hi Welcome to Webpage</h2>
        <br/>

            <input type='button' style='width:90px;height:30px;' onclick='locationChange()' value='VoiceRecorder'>
        </center>
    </body>
</html>
import UIKit
import CoreLocation

class ViewController: UIViewController  , UIWebViewDelegate , CLLocationManagerDelegate  {
     var locationManager:CLLocationManager!
    @IBOutlet var WebView: UIWebView!
    @IBOutlet var myActivityIndicator: UIActivityIndicatorView!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        loadaddress()

    }

    func loadaddress()
    {
        let requestURL = NSURL (string: "http://codersaddicts.com/Mahdi/TPA1/index.php")
        let request = NSURLRequest(url: requestURL as! URL);
        WebView.loadRequest(request as URLRequest)
    }

    func webViewDidStartLoad(_ WebView: UIWebView)
    {
        myActivityIndicator.startAnimating()
    }
    func webViewDidFinishLoad(_ WebView: UIWebView)
    {
        myActivityIndicator.stopAnimating()

    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

Image to show the two views i have created

enter image description here

Souad
  • 4,856
  • 15
  • 80
  • 140

0 Answers0