[英]UIToolBar not displaying
我正在嘗試構建一個帶有頂部UIToolBar
的webview的應用程序。 該應用程序僅供我們公司內部使用,我受命負責構建此應用程序。 如果用戶要閱讀從我們內部網站加載的常見問題解答,則會顯示該特定的Webview。 該UIToolBar
作為模式加載,需要UIToolBar
的按鈕將其關閉。 但是,我沒有任何運氣。
當前實現僅顯示http://www.google.com,而沒有UIToolBar
。 我究竟做錯了什么?
LoginWebviewController.h
#import <UIKit/UIKit.h>
@interface LoginWebViewController : UIViewController
@end
LoginWebviewController.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
您的LoginWebViewController
可能不會成為UINavigationViewController
的一部分。
檢查您的情節提要文件,它是初始視圖控制器。 如果是普通的UIViewController
,則需要將UINavigationViewController
用作initialViewController。 但是,我建議您在LoginWebViewController
添加一個UIToolbar
並在LoginWebViewController
設置按鈕。 如果您未在應用程序中進行任何導航(因為它是基於Webview的應用程序),那會很好
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.