Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8559123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:58:05+00:00 2026-06-11T15:58:05+00:00

I am using the web view to display the HTML contents and using some

  • 0

I am using the web view to display the HTML contents and using some methods for orientation but as i change the orientation form landscape to portrait for the first time the text goes out from the view.And when i scroll from portrait to another page it shows me the perfectly.May be this happens because of the width from landscape to portrait.

The code and method i use is below:

Setting the page size

- (void)setPageSize:(NSString *)orientation {
NSLog(@"• Set size for orientation: %@", orientation);

pageWidth = screenBounds.size.width;
pageHeight = screenBounds.size.height;
if ([orientation isEqualToString:@"landscape"]) {
    pageWidth = screenBounds.size.height;
    pageHeight = screenBounds.size.width;
}

}

for orientations

- (NSString *)getCurrentInterfaceOrientation {
if ([availableOrientation isEqualToString:@"portrait"] || [availableOrientation isEqualToString:@"landscape"])
{
    return availableOrientation;
} 
else {
    // WARNING!!! Seems like checking [[UIDevice currentDevice] orientation] against "UIInterfaceOrientationPortrait" is broken (return FALSE with the device in portrait orientation)
    // Safe solution: always check if the device is in landscape orientation, if FALSE then it's in portrait.
    if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {
        return @"landscape";
    } else {
        return @"portrait";
    }
}

}

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
if ([availableOrientation isEqualToString:@"portrait"]) {
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
} else if ([availableOrientation isEqualToString:@"landscape"]) {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
} else {
    return YES;
}   

}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
// Notify the index view
[indexViewController willRotate];

// Since the UIWebView doesn't handle orientationchange events correctly we have to do handle them ourselves 
// 1. Set the correct value for window.orientation property
NSString *jsOrientationGetter;
switch (toInterfaceOrientation) {
    case UIDeviceOrientationPortrait:
        jsOrientationGetter = @"window.__defineGetter__('orientation', function() { return 0; });";
        break;
    case UIDeviceOrientationLandscapeLeft:
        jsOrientationGetter = @"window.__defineGetter__('orientation', function() { return 90; });";
        break;
    case UIDeviceOrientationLandscapeRight:
        jsOrientationGetter = @"window.__defineGetter__('orientation', function() { return -90; });";
        break;
    case UIDeviceOrientationPortraitUpsideDown:
        jsOrientationGetter = @"window.__defineGetter__('orientation', function() { return 180; });";
        break;
    default:
        break;
}

// 2. Create and dispatch a orientationchange event    
NSString *jsOrientationChange = @"if (typeof bakerOrientationChangeEvent === 'undefined') {\
                                      var bakerOrientationChangeEvent = document.createEvent('Events');\
                                          bakerOrientationChangeEvent.initEvent('orientationchange', true, false);\
                                  }; window.dispatchEvent(bakerOrientationChangeEvent)";

// 3. Merge the scripts and load them on the current UIWebView
NSString *jsCommand = [jsOrientationGetter stringByAppendingString:jsOrientationChange];
[currPage stringByEvaluatingJavaScriptFromString:jsCommand];

}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[indexViewController rotateFromOrientation:fromInterfaceOrientation toOrientation:self.interfaceOrientation];

[self setPageSize:[self getCurrentInterfaceOrientation]];
[self getPageHeight];    
[self resetScrollView];

please help me.where do i go wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:58:06+00:00Added an answer on June 11, 2026 at 3:58 pm

    I found that the problem is not with the code i have changed the page size for the html page and it now works corectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a web view using jsp, javascript and html. I have a
I want to create my very first web app using HTML, MySQL, PHP and
i am using automation (i.e. COM automation) to display some HTML in Internet Explorer
I want to load a web view using loadUrl that has query params in
I am using a webview and on that web view i have a image.
I did one sample application using WebView, in that web view the URL comes
I have successfully been using the eclipse Indigo internal browser to view my web
I have a web application where I am using asp.net tree view control to
I am using a QWebView to display some content and I want to use
I have an Webview in my application where i display the html content using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.