0
在我的應用程序中,我添加了一個新的控制器xib文件。我有一個Web視圖,顯示一些HTML數據。現在的問題是它沒有在屏幕上的任何位置顯示導航欄,但它顯示了Web視圖中的數據。我可以在xib文件中看到導航欄。下面是在.m文件的代碼..iOS ::導航欄不顯示在iOS中
#import "TechTermViewController.h"
#import "PictureViewController.h"
@implementation TechTermViewController
@synthesize mydef;
@synthesize defhtml;
@synthesize appDelegate;
@synthesize myWebView;
@synthesize randomObject;
@synthesize preferences;
- (void)loadView {
// the base view for this view controller
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor whiteColor];
// important for view orientation rotation
contentView.autoresizesSubviews = YES;
contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.view = contentView;
[contentView release];
//Initialize the WebView -----------------------------------------------------------
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
// webFrame.origin.y += kTopMargin + 5.0; // leave from the URL input field and its label
//webFrame.origin.y -= 0.0;
myWebView = [[UIWebView alloc] initWithFrame:webFrame];
myWebView.backgroundColor = [UIColor blackColor];
myWebView.backgroundColor = [UIColor whiteColor];
myWebView.scalesPageToFit = YES;
// myWebView.detectsPhoneNumbers = NO;
myWebView.dataDetectorTypes = UIDataDetectorTypeLink;
myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
myWebView.delegate = self;
[self.view addSubview: myWebView];
[self loadDefHTML:YES];
//[[self navigationController] setNavigationBarHidden:NO animated:YES];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
[self loadDefHTML:YES];
//[[self navigationController] setNavigationBarHidden:NO animated:YES];
}
//make it happen
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self loadDefHTML:YES];
//[[self navigationController] setNavigationBarHidden:NO animated:YES];
}
//Remove the toolbar if we are disappearing
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[myWebView stopLoading];
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
- (IBAction) doDone:(id)sender {
if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:) ]) {
[self dismissViewControllerAnimated:YES completion:nil];
}
else {
[[self parentViewController] dismissModalViewControllerAnimated:YES];
}
}
XIB ::
任何想法?
如果我刪除loadview方法,那麼它顯示導航欄,但不是web視圖數據....爲什麼這樣? – Anjali
myWebView.scalesPageToFit = YES; 檢查,也許這是原因。 –