<tfoot id='LV9Y4'></tfoot>

<small id='LV9Y4'></small><noframes id='LV9Y4'>

      • <bdo id='LV9Y4'></bdo><ul id='LV9Y4'></ul>
    1. <legend id='LV9Y4'><style id='LV9Y4'><dir id='LV9Y4'><q id='LV9Y4'></q></dir></style></legend>
      <i id='LV9Y4'><tr id='LV9Y4'><dt id='LV9Y4'><q id='LV9Y4'><span id='LV9Y4'><b id='LV9Y4'><form id='LV9Y4'><ins id='LV9Y4'></ins><ul id='LV9Y4'></ul><sub id='LV9Y4'></sub></form><legend id='LV9Y4'></legend><bdo id='LV9Y4'><pre id='LV9Y4'><center id='LV9Y4'></center></pre></bdo></b><th id='LV9Y4'></th></span></q></dt></tr></i><div id='LV9Y4'><tfoot id='LV9Y4'></tfoot><dl id='LV9Y4'><fieldset id='LV9Y4'></fieldset></dl></div>

      Webview 自动调整大小为 iphone 中的纵向和横向视图

      时间:2023-10-22
      <tfoot id='lDKk5'></tfoot>
    2. <legend id='lDKk5'><style id='lDKk5'><dir id='lDKk5'><q id='lDKk5'></q></dir></style></legend>

          <bdo id='lDKk5'></bdo><ul id='lDKk5'></ul>

                <tbody id='lDKk5'></tbody>
            1. <i id='lDKk5'><tr id='lDKk5'><dt id='lDKk5'><q id='lDKk5'><span id='lDKk5'><b id='lDKk5'><form id='lDKk5'><ins id='lDKk5'></ins><ul id='lDKk5'></ul><sub id='lDKk5'></sub></form><legend id='lDKk5'></legend><bdo id='lDKk5'><pre id='lDKk5'><center id='lDKk5'></center></pre></bdo></b><th id='lDKk5'></th></span></q></dt></tr></i><div id='lDKk5'><tfoot id='lDKk5'></tfoot><dl id='lDKk5'><fieldset id='lDKk5'></fieldset></dl></div>

              <small id='lDKk5'></small><noframes id='lDKk5'>

                本文介绍了Webview 自动调整大小为 iphone 中的纵向和横向视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我是 iphone 开发新手.在我的应用程序中,我想在具有 c 纵向方向的设备中显示 Web 视图.它还应该支持横向方向.我使用了以下方法,但没有预期的输出.

                I am new to iphone development.In my app, i want to display the web view in device with c portrait Orientation.It should also support landscape orientation. I used the below method but there is no expected output.

                - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
                {
                
                return (interfaceOrientation == UIInterfaceOrientationPortrait || 
                
                 interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == 
                
                UIInterfaceOrientationLandscapeRight);
                }
                

                请指导我.请帮助我.谢谢

                please guide me.Please help me out.Thanks

                推荐答案

                我想你已经为 webview 设置了固定框架,这对实现方向改变没有帮助

                I think you have set the fixed frame for webview.That will not help while implementing orientation chage

                试试这个:

                使用此代码显示网络视图.使用您的 URL 更改堆栈溢出 URL;

                Use this code for displaying the web-view.Change the stack-overflow URL with your 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];
                

                支持方向

                   - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation 
                {
                return YES;
                
                }
                

                网页视图随方向变化

                - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
                {
                if(fromInterfaceOrientation == UIInterfaceOrientationPortrait){
                 [webView stringByEvaluatingJavaScriptFromString:@"rotate(0)"];
                
                }
                else{
                    [webView stringByEvaluatingJavaScriptFromString:@"rotate(1)"];
                }
                }
                

                希望以上内容能满足您的要求.一切顺利.

                Hope the above will satisfy your requirement. All the best.

                这篇关于Webview 自动调整大小为 iphone 中的纵向和横向视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:即使页面稍后加载,也使用 UIWebView 调用 didFailLoadWithError 下一篇:水平滚动的 PDF 视图

                相关文章

                <small id='AEAir'></small><noframes id='AEAir'>

                    <bdo id='AEAir'></bdo><ul id='AEAir'></ul>
                    <tfoot id='AEAir'></tfoot>

                    <legend id='AEAir'><style id='AEAir'><dir id='AEAir'><q id='AEAir'></q></dir></style></legend>
                    <i id='AEAir'><tr id='AEAir'><dt id='AEAir'><q id='AEAir'><span id='AEAir'><b id='AEAir'><form id='AEAir'><ins id='AEAir'></ins><ul id='AEAir'></ul><sub id='AEAir'></sub></form><legend id='AEAir'></legend><bdo id='AEAir'><pre id='AEAir'><center id='AEAir'></center></pre></bdo></b><th id='AEAir'></th></span></q></dt></tr></i><div id='AEAir'><tfoot id='AEAir'></tfoot><dl id='AEAir'><fieldset id='AEAir'></fieldset></dl></div>