Je pense que vous avez défini le cadre fixé pour webview.That ne sera pas utile en mettant en œuvre l'orientation chage
Essayez ceci:
Utilisez ce code pour afficher le web-view.Change la pile l'URL de -overflow avec votre URL;
contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.view = contentView;
self.view.autoresizesSubviews = YES;
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webFrame.origin.y -= 20.0;
webView = [[UIWebView alloc] initWithFrame:webFrame];
[contentView addSubview:webView];
webView.scalesPageToFit = YES;
webView.autoresizesSubviews = YES;
webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
[webView setBackgroundColor:[UIColor clearColor]];
NSString *urlAddress = @"https://www.stackoverflow.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
webView.delegate =self;
[webView release];
Pour soutenir l'orientation
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation
{
return YES;
}
Pour le changement Web avec vue orientation
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if(fromInterfaceOrientation == UIInterfaceOrientationPortrait){
[webView stringByEvaluatingJavaScriptFromString:@"rotate(0)"];
}
else{
[webView stringByEvaluatingJavaScriptFromString:@"rotate(1)"];
}
}
Espérons que ce qui précède satisfaire vos besoins. Tout le meilleur.
Merci. Je veux afficher la barre d'outils dans mon webview? Comment puis-je atteindre cet objectif?. Je ne suis pas en mesure de voir la barre d'outils dans mon webview. – Pugal
@pugal Insérer la barre d'onglets comme sous-vue ... [self.view insertSubview: tBar belowSubview: contentView]; Modifiez tBar sur la barre d'outils que vous avez utilisée. – Warrior