簡體   English   中英

UIToolBar不顯示

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM