码迷,mamicode.com
首页 > 其他好文 > 详细

创建浏览器的基本

时间:2014-10-13 23:23:37      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   os   ar   for   sp   div   on   

#import "ViewController.h"

@interface ViewController ()<UIScrollViewDelegate>  //保包括这个viewdelegat协议
          
@property (weak, nonatomic) IBOutlet UITextField *search;   //这是输入框
@property (weak, nonatomic) IBOutlet UIWebView *viewbrows; // 这个是浏览器界面视图
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];     //初始化载入
    
}
- (IBAction)go:(id)sender {
    NSString *path =self.search.text;   //字符串指针指向输入的文本
    //[path stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)]//这个应该是转换代码格式
    
    
    if (![path hasPrefix:@"http://"]) {        //表示判断path前缀是否是http://
                                                             
path=[@"http://" stringByAppendingString:path];        没有则添加http://在path前面

    }                                                        
    NSURL *url =[NSURL URLWithString:path];             //用url指针指向字符串格式的url path     
    NSURLRequest *request =[NSURLRequest requestWithURL:url];   request请求指向url
    [self.viewbrows loadRequest:request];                                   载入请求的url
    [self.view endEditing:YES];                                //当使徒运行完成后键盘会缩回
}
- (IBAction)went:(id)sender {
    [self.viewbrows goForward];          //前进
}
- (IBAction)back:(id)sender {
    [self.viewbrows goBack];            //后退
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

 

创建浏览器的基本

标签:blog   http   io   os   ar   for   sp   div   on   

原文地址:http://www.cnblogs.com/wangweixl/p/4023091.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!