UIWebView を使用して、iPhone アプリケーション内からモバイル Web サイトにアクセスしています。進むボタンと戻るボタンの追加についてサポートが必要です。私はこれに本当に慣れていないので、誰かが良い詳細を提供できれば、本当に助けていただければ幸いです.
ここに私が持っているものがあります:
UIWebView *webView1 = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 480, 251)];
[contentView addSubview:webView1];
webView1.alpha = 1.0;
webView1.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[webView1 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.logsitall.com/m"]]];
webView1.scalesPageToFit = YES;
[webView1 release];
contentView.frame = self.view.bounds;
[self.view addSubview:contentView];
[contentView release];
}
- (void)viewDidUnload {
[self setWebView:nil];
[super viewDidUnload];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:animated];
}
@end
最終的なコード:
//header
@interface MywebsiteViewController : UIViewController <UIWebViewDelegate>
{
IBOutlet UIWebView *aWebView;
}
@property (nonatomic, retain) UIWebView *aWebView;
@end
//implementation
- (void)viewWillAppear:(BOOL)animated {
self.aWebView.delegate = self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *myURL = [NSURL URLWithString:@"http://www.WebSiteToLoad.com"];
NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL];
[aWebView loadRequest:myRequest];
}
#pragma mark UIWebViewDelegate
- (void)webViewDidStartLoad:(UIWebView *)webView{
//show indicator while loading website
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
//turn off indicator and display the name of the website in the navBar
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
self.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
}