views:

1175

answers:

8

Hi there! Im using a UIWebView to access a website, when i rotate the phone (landscape) the UIWebView is properly resized and the scrollbar are on the right place (on the right edge...) but when i acess any of input fields to fill the information required and exit it the UIWebView scrollbar jumps to the middle of screen (looks like it get back to 320, the width of the screen on portrait). Some useful info, this program was created using IB, have lots of outlets, im thinking about in do (redo) everything programmatically cause i was not the author of the first version... If anyone have seen this before plz let me know..

Thanks in advance!

A: 

I reported a Bug on begreport.apple.com about this issue.

And today (04/21/2010) got an answer!

"Hello Paulo,

This is a follow-up to Bug ID# 7392537. Engineering believes this issue has been addressed in iPhone OS 4.0 beta seed 2. (8A248c)

After installing the iPhone OS 4.0b2 software, please update this bug report with your results.

Thank you for your time. We truly appreciate your assistance in helping us discover and isolate bugs. Best Regards,

Patrick Collins Apple Developer Connection Worldwide Developer Relations"

Paulo Ferreira
A: 

I received a response from Apple about the possible bug reported, they asked for a sample code that can reproduce the problem, i sent to them and im posting it here so you can test too:

//
//  viewController.m
//  TesteWebview
//
//  Created by GecanMobile01 on 13/11/09.
//  Copyright xxx All rights reserved.
//

#import "viewController.h"


@implementation viewController

@synthesize vw, wv;

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
    vw = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    [vw setBackgroundColor:[UIColor grayColor]];
    vw.autoresizesSubviews = YES;
    self.view = vw;
    wv = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

    [self.view addSubview:wv];
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    NSURL *urlId = [NSURL URLWithString:@"https://www.google.com"];
    NSURLRequest *theRequest = [NSURLRequest requestWithURL:urlId cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:(NSTimeInterval)10.0];
    [wv loadRequest:theRequest];
    [super viewDidLoad];
}

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    CGRect  cgrWebView;
    BOOL bChangeOrientation = NO;
    if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){
     if (interfaceOrientation == UIInterfaceOrientationPortrait) {
      cgrWebView = CGRectMake(0.0, 0.0, 320.0, 460.0);
      bChangeOrientation = YES;
     } else {
      cgrWebView = CGRectMake(0.0, 0.0, 480.0, 320.0);
      bChangeOrientation = YES;
     }
     [wv setFrame:cgrWebView];
    }
    return bChangeOrientation;
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
Paulo Ferreira
A: 

Did you ever get a response to this? I am having the same problem.

Lou
+1  A: 

In my test case I found that I can replicate this problem by going to a web site that accepts input, invoking the keyboard, dismissing the keyboard (with or without entering any input) and now the vertical scroll bar's display is in the Portrait position.

I tested with and without a NIB and the results are consistent. Once the keyboard is invoked, the vertical scroll bar will remain at the Portrait coordinates when the phone (or simulator) is in Landscape mode.

I submitted case# 7428286.

Lou
A: 

Yeah this seams to be an error, I have the same issue here. I try to remove the scrollBars at all but somehow "[browser showVerticalScrollBars:NO]" or something like this doesn't work...

does anyone know the solution?

Artur
A: 

I was facing the same problem but I set the frame of web view in

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
{
BOOL orientation = NO;
    if(interfaceOrientation == UIInterfaceOrientationPortrait)
    {
          [webView setFrame:CGRectMake(0, 0, 320, 480)];
             orientation = YES;
        return orientation;
         }else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
            [webView setFrame:CGRectMake(0, 0, 480, 320)];
             orientation = YES;
        return orientation; 
         }else {
        orientation = NO;
        return orientation;
    }
}
ashish
A: 

Has anyone received an update from Apple on this yet? I just ran into the same problem and don't want re-open the issue if it has a workaround.

Jeff Kindred
+1  A: 

Dont add your webview into self.view just assign it.Simple thing works like awesome

wv = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

[self.view addSubview:wv];

instead do

self.view = wv;

It works! Thanks.
Paulo Ferreira