Web ページを読み込めません。なぜこれが考えられるのでしょうか?Webview のフレーム (デバッガーから出力)
<UIWebView: 0x8a49840; frame = (0 0; 320 241); autoresize = TM+BM; layer = <CALayer: 0x8a498f0>>
これが私のコードです:
#import "ViewController.h"
@interface ViewController () <UIWebViewDelegate>
@end
@implementation ViewController
@synthesize webview;
- (void)viewDidLoad
{
[super viewDidLoad];
self.webview.delegate = self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)viewDidAppear:(BOOL)animated
{
}
- (IBAction)buttonPress:(id)sender {
NSLog(@"pressed");
NSURL *theUrl = [NSURL URLWithString:@"www.google.com"];
NSError *e ;
// just for test - ALSO returning nil!!!
NSString *str = [NSString stringWithContentsOfURL:theUrl encoding:NSUTF8StringEncoding error:&e];
NSLog(@"%@",str);
NSURLRequest *theRequest = [NSURLRequest requestWithURL:theUrl];
[self.webview loadRequest:theRequest];
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
NSLog(@"page is loading");
}
// this method is never called
-(void)webViewDidFinishLoad:(UIWebView *)webView {
NSLog(@"finished loading");
}
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}
@end