【发布时间】:2015-07-28 00:35:12
【问题描述】:
我有大约 +3 个 UIwebViews,我如何编写每个代码以访问不同的 URL。
这里是我的 ViewController.m 文件中的代码
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIWebView *webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)];
NSString *url=@"http://test.bithumor.co/test22.php";
NSURL *nsurl=[NSURL URLWithString:url];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webview loadRequest:nsrequest];
[self.view addSubview:webview];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
如何为每个 UIwebViews 保留相同的确切代码,但让每个 UIwebViews 访问不同的网页?
示例:
UIwebView1 = http://example.com/1
UIwebView2 = http://example.com/2
UIwebView1 = http://example.com/3
【问题讨论】:
标签: ios objective-c xcode uiwebview