我正在尝试构建一个具有顶部 webview 的应用程序UIToolBar
。这个应用程序是供我们公司内部使用的,我的任务是构建它。如果用户想要阅读从我们的内部网站加载的常见问题解答,则会出现这个特定的 web 视图。此 web 视图作为模式加载,需要一个按钮UIToolBar
来关闭它。但是,我没有任何运气。
当前的实现只显示http://www.google.com而没有UIToolBar
. 我究竟做错了什么?
登录WebviewController.h
#import <UIKit/UIKit.h>
@interface LoginWebViewController : UIViewController
@end
登录WebviewController.m
#import "LoginWebViewController.h"
@interface LoginWebViewController ()
@end
@implementation LoginWebViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Log in";
// Do any additional setup after loading the view.
[self.navigationController setNavigationBarHidden:NO animated:YES];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(barButtonBackPressed:)];
UIWebView *webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 1024,768)];
NSString *url=@"http://www.google.com";
NSURL *nsurl=[NSURL URLWithString:url];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webview loadRequest:nsrequest];
[self.view addSubview:webview];
}
-(void)barButtonBackPressed:(id)sender{
[self dismissModalViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end