UIWebView的使用,简单浏览器的实现
#import "ViewController.h"
@interface ViewController () <UIWebViewDelegate>
@property(nonatomic,weak)UIWebView* web;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self _setTextField];
[self _loadWebView];
}
#pragma mark - 设置输入框
- (void)_setTextField{
self.tf.clearButtonMode=UITextFieldViewModeWhileEditing;
}
#pragma mark - 载入WebView
- (void)_loadWebView{
UIWebView* web=[[UIWebView alloc] init];
web.frame=CGRectMake(0,self.view.frame.size.height,self.view.frame.size.width,self.view.frame.size.height-42 );
self.web=web;
web.delegate=self;
[self.view addSubview:web];
}
#pragma mark - 放弃第一响应
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.tf resignFirstResponder];
}
#pragma mark - Action
- (IBAction)backAction:(id)sender {
[self.web goBack];
// self.web.frame=CGRectMake(0,self.view.frame.size.height,self.view.frame.size.width,self.view.frame.size.height-42 );
}
- (IBAction)forwardAction:(id)sender {
[self.web goForward];
self.web.frame=CGRectMake(0,20,self.view.frame.size.width,self.view.frame.size.height-50);
}
- (IBAction)undoAction:(id)sender {
[self.web stopLoading];
}
- (IBAction)refreshAction:(id)sender {
[self.web reload];
}
- (IBAction)searchAction:(id)sender {
[self.tf resignFirstResponder];
self.web.frame=CGRectMake(0,20,self.view.frame.size.width,self.view.frame.size.height-60);
[self _sendRequest];
}
#pragma mark - UIWebViewDelegate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView{
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
// NSLog(@"%d===%d",[webView canGoBack],[webView canGoForward]);
self.backBt.enabled=[webView canGoBack];
self.forwardBt.enabled=[webView canGoForward];
self.refresh.enabled=([webView canGoBack] ||[webView canGoForward]);
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
NSLog(@"%@",error);
}
- (void)_sendRequest{
//http://www.baidu.com
NSURL* url=[NSURL URLWithString:self.tf.text];
NSURLRequest* request=[NSURLRequest requestWithURL:url];
[self.web loadRequest:request];
}
@end
UIWebView的使用,简单浏览器的实现的更多相关文章
- 基于Gecko内核的简单浏览器实现
分享一个基于Gecko内核的简单浏览器实现过程. 项目需要需要开发一个简单浏览器,由于被访问的网页中有大量Apng做的动画,使用IE内核的webbrowser不能播放,使用基于WebKit和Cefsh ...
- IOS开发-UI学习-UIWebView,简单浏览器的制作
制作一个简单的浏览器,包含网址输入框,Search按钮,前进.回退按钮,UIWebView就这几个简单的控件. UITextField:用来输入网址: UIbuttom:实现前进,后退,搜索等功能: ...
- 爬虫技术 -- 进阶学习(八)模拟简单浏览器(附c#代码)
由于最近在做毕业设计,需要用到一些简单的浏览器功能,于是学习了一下,顺便写篇博客~~大牛请勿喷,菜鸟练练手~ 实现界面如下:(简单朴素版@_@||) button_go实现如下: private vo ...
- 爬虫技术(五)-- 模拟简单浏览器(附c#代码)
由于最近在做毕业设计,需要用到一些简单的浏览器功能,于是学习了一下,顺便写篇博客~~大牛请勿喷,菜鸟练练手~ 实现界面如下:(简单朴素版@_@||) button_go实现如下: private vo ...
- C# 网络编程之最简单浏览器实现
最近学习C#网络编程的HTTP协议编程,HTTP即Hypertext Transfer Protocol的缩写,意为:超文本传输协议. 其中与HTTP相关的知识主要有六个类的知识,分别是 (1).Ht ...
- 在 .NET 中开发基于 Chrome 内核的浏览器-创建一个简单浏览器
首先在 http://www.cftea.com/tools/downloads/Cef.zip 下载文件包. 一.将文件解压拖入到 Visual Studio 对应的 WinForm 项目中. 二. ...
- 001 - 使用鸿蒙WebView创建简单浏览器 step 1
打开官网,找到WebView的文档(模拟器不支持) 鸿蒙webview的开发指南(原始链接,方便大家识别并点击):https://developer.harmonyos.com/cn/docs/doc ...
- python3使用pyqt5制作一个超简单浏览器
我们使用的是QWebview模块,这里也主要是展示下QWebview的用法. 之前在网上找了半天的解析网页的内容,都不是很清楚. 这是核心代码: webview = Qwebview() webvie ...
- [flex] as3.0 实现基于air的简单浏览器
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx= ...
随机推荐
- 【转】在Tomcat配置JNDI数据源的三种方式
在我过去工作的过程中,开发用服务器一般都是Tomcat 数据源的配置往往都是在applicationContext.xml中配置一个dataSource的bean 然后在部署时再修改JNDI配置 我猜 ...
- 使用 Apache MINA2 实现 Web 系统的消息中间件
本文将介绍如何使用 Apache MINA2(以下简称 MINA2)解决复杂 Web 系统内各子系统之间同步消息中间件的问题.MINA2 为开发高性能和高可用性的网络应用程序提供了非常便利的框架.从本 ...
- 32、handler更新控件值
import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os. ...
- GIS中相交的定义(OGC相交的定义)
我们常用GIS中的相交,比如在地图漫游的时候,屏幕显示的图形和屏幕这个包络线就是相交的关系.我们常用的GIS工具,拉框查询,这个用到的也是相交. 首先题目开起来很简单(开始的时候我是这样想的),但是做 ...
- 【原】Storm 守护线程容错机制
Storm入门教程 1. Storm基础 Storm Storm主要特点 Storm基本概念 Storm调度器 Storm配置 Guaranteeing Message Processing(消息处理 ...
- bzoj 1058 [ZJOI2007]报表统计(set)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1058 [题意] 一个序列,提供插入,查询相邻最小差值,查询任意最小差值的操作. [思路 ...
- HW5.29
public class Solution { public static void main(String[] args) { int n1 = (int)(Math.random() * 5 + ...
- leetcode@ [307] Range Sum Query - Mutable / 线段树模板
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive ...
- debian 显示器使用自定义分辨率
比如你要使用 1440x900 的自定义分辨率,先利用 cvt 计算一个新的 modeline $ cvt 1440 900 输出为: # 1440x900 59.89 Hz (CVT 1.30MA ...
- hdu4777-Rabbit Kingdom
题意:求区间内与其他任何数都互质的数的个数. 题解:求出每个数左右互质的边界.然后对询问排序,通过树状数组求解. 讲道理真的好难啊= = http://blog.csdn.net/dyx404514/ ...