ios项目开发(webview初步):
时间:2014-05-22 12:22:35
收藏:0
阅读:352

1 . 建立一个 single view class
2 . 在view controller上建立3个控件 text view,button, webview
3 . 将 text view , webview风别命名为 url,web
//// ViewController.h// webview1//// Created by HeJiasheng on 13-11-12.// Copyright (c) 2013年 HeJiasheng. All rights reserved.//#import <UIKit/UIKit.h>@interface ViewController : UIViewController@property (strong, nonatomic) IBOutlet UITextField *url;@property (strong, nonatomic) IBOutlet UIWebView *web;@end
4 . 将按钮的 单击事件 创建为bClick
@implementation ViewController- (IBAction)bClick:(id)sender {NSURL *url1 =[NSURL URLWithString:self.url.text];NSURLRequest *request =[NSURLRequest requestWithURL:url1];[self.web loadRequest:request];}
这样就可以使用了, 在text里输入网址,注意要带上 http://
评论(0)