
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
How to create a WebView in iOS/iPhone?
To create a web view in iOS we'll use Webkit framework of iOS. Previously UIWebView was used to create web views but that has been deprecated now.
We'll use WebKit View in this project.
Create a new project and from object library drag and drop webKit View to the ViewController.
Give constraints as per your requirement.
Make an outlet connection to the webKit in ViewController.
We'll open facebook in this example using the code below.
let url = URL(string: "https://www.facebook.com") override func viewDidLoad() { super.viewDidLoad() let request = URLRequest.init(url: self.url!) self.wbView.load(request) }
Now finally we need to add a key App Transport Security Settings in info.plist.
Open your info.plist file as source code and paste the following code −
<key>NSAppTransportSecurity</key> <dict> <!--Include to allow all connections (DANGER)--> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
Note − In devices running iOS 10.0 or later we also need to add Photo library usage description and Camera usage description in the info.plist
NSPhotoLibraryUsageDescription NSCameraUsageDescription
This is how the app looks when running on a simulator.
- Related Articles
- How to create a WebView in an iOS App using Swift?
- How to create a Border, Border radius, and shadow to a UIView in iPhone/iOS?
- How to take a screenshot programmatically in iPhone/iOS?
- How to parse JSON object in iPhone/iOS?
- How to compare two NSDates in iPhone/iOS?
- How to add 1 day to a Date in iOS/iPhone?
- How to programmatically prevent scrolling in WebView of iOS?
- How to access RESTFul services from iOS/iPhone?
- How to add line break for UILabel in iOS/iPhone?
- How to create a WebView in android app?
- How do I draw a shadow under a UIView in iPhone/iOS?
- How to request permission programatically to use location services in iPhone/iOS?
- How to use Bold & Non-Bold Text In A Single UILabel in iOS/iPhone?
- How to get the MAC address of an iOS/iPhone programmatically?
- How to create a WebView in an Android App using Kotlin?
